r2375 - trunk/varnish-cache/lib/libvarnish

des at projects.linpro.no des at projects.linpro.no
Wed Jan 23 16:45:03 CET 2008


Author: des
Date: 2008-01-23 16:45:03 +0100 (Wed, 23 Jan 2008)
New Revision: 2375

Modified:
   trunk/varnish-cache/lib/libvarnish/vss.c
Log:
Don't assume that res0 != NULL automatically means i == 0.  I can't say for
sure (without more coffee) that the assumption is incorrect, but it makes
the code gratuitously non-transparent.

Coverity Scan (CID:8)


Modified: trunk/varnish-cache/lib/libvarnish/vss.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/vss.c	2008-01-23 13:45:48 UTC (rev 2374)
+++ trunk/varnish-cache/lib/libvarnish/vss.c	2008-01-23 15:45:03 UTC (rev 2375)
@@ -135,8 +135,13 @@
 		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;




More information about the varnish-commit mailing list