r1703 - trunk/varnish-cache/lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Sun Jul 15 13:04:53 CEST 2007


Author: phk
Date: 2007-07-15 13:04:52 +0200 (Sun, 15 Jul 2007)
New Revision: 1703

Modified:
   trunk/varnish-cache/lib/libvcl/vcc_compile.c
   trunk/varnish-cache/lib/libvcl/vcc_compile.h
Log:
Don't leak the file contents either.


Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c	2007-07-15 10:58:11 UTC (rev 1702)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c	2007-07-15 11:04:52 UTC (rev 1703)
@@ -378,6 +378,8 @@
 vcc_destroy_source(struct source *sp)
 {
 
+	if (sp->freeit != NULL)
+		free(sp->freeit);
 	free(sp->name);	
 	free(sp);
 }
@@ -390,6 +392,7 @@
 	char *f;
 	int i;
 	struct stat st;
+	struct source *sp;
 
 	if (fd < 0) {
 		fd = open(fn, O_RDONLY);
@@ -406,7 +409,9 @@
 	assert(i == st.st_size);
 	close(fd);
 	f[i] = '\0';
-	return (vcc_new_source(f, f + i, fn));
+	sp = vcc_new_source(f, f + i, fn);
+	sp->freeit = f;
+	return (sp);
 }
 
 /*--------------------------------------------------------------------*/

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h	2007-07-15 10:58:11 UTC (rev 1702)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h	2007-07-15 11:04:52 UTC (rev 1703)
@@ -45,6 +45,7 @@
 	const char		*b;
 	const char		*e;
 	unsigned		idx;
+	char			*freeit;
 };
 
 struct token {




More information about the varnish-commit mailing list