From: Nick Mathewson Date: Sat, 19 Apr 2014 00:26:47 +0000 (-0400) Subject: scan-build: Add a check for result from getaddrinfo X-Git-Tag: tor-0.2.5.4-alpha~14^2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=08325b58bef83bfed181c493f269ef57477152c0;p=thirdparty%2Ftor.git scan-build: Add a check for result from getaddrinfo As documented, getaddrinfo always sets its result when it returns no error. But scan-build doesn't know that, and thinks we might be def --- diff --git a/src/common/address.c b/src/common/address.c index e5930dedca..2825b123da 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -236,7 +236,9 @@ tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr) hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; err = sandbox_getaddrinfo(name, NULL, &hints, &res); - if (!err) { + /* The check for 'res' here shouldn't be necessary, but it makes static + * analysis tools happy. */ + if (!err && res) { best = NULL; for (res_p = res; res_p; res_p = res_p->ai_next) { if (family == AF_UNSPEC) {