]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Made Ip::Address::fromHost() handle nil pointers after fd9c47d. (#25)
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 20 Jul 2017 03:45:59 +0000 (21:45 -0600)
committerAmos Jeffries <yadij@users.noreply.github.com>
Thu, 20 Jul 2017 03:45:59 +0000 (15:45 +1200)
No functionality changes expected. Nobody was passing nil pointers to
this code before or after fd9c47d AFAICT, but now that this code is
exposed as a public method, it must handle nil pointers.

Detected by Coverity Scan. Issue 1415049 (FORWARD_NULL).

src/ip/Address.cc

index 36309ad83d95e9fb58950966bffbd7a098ccc17e..9ae561a262bd6869e616646371decc4be54ca1f3 100644 (file)
@@ -917,7 +917,10 @@ Ip::Address::fromHost(const char *host)
 {
     setEmpty();
 
-    if (!host || host[0] != '[')
+    if (!host)
+        return false;
+
+    if (host[0] != '[')
         return lookupHostIP(host, true); // no brackets
 
     /* unwrap a bracketed [presumably IPv6] address, presumably without port */