]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
scan-build: Add a check for result from getaddrinfo
authorNick Mathewson <nickm@torproject.org>
Sat, 19 Apr 2014 00:26:47 +0000 (20:26 -0400)
committerNick Mathewson <nickm@torproject.org>
Sat, 19 Apr 2014 00:26:47 +0000 (20:26 -0400)
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

src/common/address.c

index e5930dedca93cbbcab4737e3817f2bc5e4aefc3c..2825b123da08b4e2f271558e507c4b813647724e 100644 (file)
@@ -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) {