]> err.no Git - varnish/commitdiff
Don't assume that res0 != NULL automatically means i == 0. I can't say for
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 23 Jan 2008 15:45:03 +0000 (15:45 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 23 Jan 2008 15:45:03 +0000 (15:45 +0000)
sure (without more coffee) that the assumption is incorrect, but it makes
the code gratuitously non-transparent.

Coverity Scan (CID:8)

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2375 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/lib/libvarnish/vss.c

index d842a84b2b68594c9c16401bb53959fee761bc99..826b4ef6536a47c727b01ad89161fe1cf15eb50c 100644 (file)
@@ -135,8 +135,13 @@ VSS_resolve(const char *addr, const char *port, struct vss_addr ***vap)
                fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(ret));
                return (0);
        }
-       for (res = res0, i = 0; res != NULL; res = res->ai_next)
-               ++i;
+       XXXAN(res0);
+       for (res = res0, i = 0; res != NULL; res = res->ai_next, ++i)
+               /* nothing */ ;
+       if (i == 0) {
+               freeaddrinfo(res0);
+               return (0);
+       }
        va = calloc(i, sizeof *va);
        XXXAN(va);
        *vap = va;