From: Alex Rousskov Date: Thu, 20 Jul 2017 03:45:59 +0000 (-0600) Subject: Made Ip::Address::fromHost() handle nil pointers after fd9c47d. (#25) X-Git-Tag: M-staged-PR71~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=05caa1bbbc85bce55dea46a950323ac2ea8de2b8;p=thirdparty%2Fsquid.git Made Ip::Address::fromHost() handle nil pointers after fd9c47d. (#25) 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). --- diff --git a/src/ip/Address.cc b/src/ip/Address.cc index 36309ad83d..9ae561a262 100644 --- a/src/ip/Address.cc +++ b/src/ip/Address.cc @@ -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 */