r1704 - trunk/varnish-cache/lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Sun Jul 15 13:08:49 CEST 2007


Author: phk
Date: 2007-07-15 13:08:48 +0200 (Sun, 15 Jul 2007)
New Revision: 1704

Modified:
   trunk/varnish-cache/lib/libvcl/vcc_compile.c
   trunk/varnish-cache/lib/libvcl/vcc_token.c
Log:
Plug even more memory leaks in the VCL compiler.


Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c	2007-07-15 11:04:52 UTC (rev 1703)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c	2007-07-15 11:08:48 UTC (rev 1704)
@@ -514,6 +514,7 @@
 vcc_DestroyTokenList(struct tokenlist *tl, char *ret)
 {
 	struct membit *mb;
+	struct source *sp;
 	int i;
 
 	while (!TAILQ_EMPTY(&tl->membits)) {
@@ -522,6 +523,11 @@
 		free(mb->ptr);
 		free(mb);
 	}
+	while (!TAILQ_EMPTY(&tl->sources)) {
+		sp = TAILQ_FIRST(&tl->sources);
+		TAILQ_REMOVE(&tl->sources, sp, list);
+		vcc_destroy_source(sp);
+	}
 		
 	vsb_delete(tl->fh);
 	vsb_delete(tl->fc);
@@ -658,7 +664,6 @@
 	if (sp == NULL)
 		return (NULL);
 	r = vcc_CompileSource(sb, sp);
-	vcc_destroy_source(sp);
 	return (r);
 }
 
@@ -677,7 +682,6 @@
 	if (sp == NULL)
 		return (NULL);
 	r = vcc_CompileSource(sb, sp);
-	vcc_destroy_source(sp);
 	return (r);
 }
 

Modified: trunk/varnish-cache/lib/libvcl/vcc_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_token.c	2007-07-15 11:04:52 UTC (rev 1703)
+++ trunk/varnish-cache/lib/libvcl/vcc_token.c	2007-07-15 11:08:48 UTC (rev 1704)
@@ -209,7 +209,7 @@
 	unsigned char u;
 
 	assert(tl->t->tok == CSTR);
-	tl->t->dec = malloc((tl->t->e - tl->t->b) - 1);
+	tl->t->dec = TlAlloc(tl, (tl->t->e - tl->t->b) - 1);
 	assert(tl->t->dec != NULL);
 	q = tl->t->dec;
 	for (p = tl->t->b + 1; p < tl->t->e - 1; ) {




More information about the varnish-commit mailing list