r2613 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Mar 31 13:47:16 CEST 2008


Author: phk
Date: 2008-03-31 13:47:15 +0200 (Mon, 31 Mar 2008)
New Revision: 2613

Modified:
   trunk/varnish-cache/bin/varnishd/cache_vary.c
   trunk/varnish-cache/bin/varnishd/mgt_vcc.c
Log:
Fix three memory leaks related to vsb's not being vsb_deleted:

Two really bad ones in Vary processing, found by Arjan (noosius).

One isignificant one related to -b arguments being wrong,
found by FlexeLint after I taught it how to spot this kind of issue.



Modified: trunk/varnish-cache/bin/varnishd/cache_vary.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vary.c	2008-03-31 11:43:48 UTC (rev 2612)
+++ trunk/varnish-cache/bin/varnishd/cache_vary.c	2008-03-31 11:47:15 UTC (rev 2613)
@@ -69,6 +69,10 @@
 	struct vsb *sb, *sbh;
 	unsigned l;
 
+	/* No Vary: header, no worries */
+	if (!http_GetHdr(sp->obj->http, H_Vary, &v))
+		return;
+
 	/* For vary matching string */
 	sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
 	AN(sb);
@@ -77,10 +81,6 @@
 	sbh = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
 	AN(sbh);
 
-	/* No Vary: header, no worries */
-	if (!http_GetHdr(sp->obj->http, H_Vary, &v))
-		return;
-
 	for (p = v; *p; p++) {
 
 		/* Find next header-name */
@@ -130,6 +130,9 @@
 	sp->obj->vary = malloc(l);
 	AN(sp->obj->vary);
 	memcpy(sp->obj->vary, vsb_data(sb), l);
+
+	vsb_delete(sb);
+	vsb_delete(sbh);
 }
 
 int

Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c	2008-03-31 11:43:48 UTC (rev 2612)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c	2008-03-31 11:47:15 UTC (rev 2613)
@@ -423,6 +423,7 @@
 			 */
 			free(port);
 			fprintf(stderr, "invalid backend address\n");
+			vsb_delete(sb);
 			return (1);
 		}
 




More information about the varnish-commit mailing list