From: phk Date: Sun, 15 Jul 2007 11:04:52 +0000 (+0000) Subject: Don't leak the file contents either. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e02252970858b7cca13a6d25def53590b5c418bf;p=varnish Don't leak the file contents either. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1703 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/lib/libvcl/vcc_compile.c b/varnish-cache/lib/libvcl/vcc_compile.c index 07eca8e2..440456bf 100644 --- a/varnish-cache/lib/libvcl/vcc_compile.c +++ b/varnish-cache/lib/libvcl/vcc_compile.c @@ -378,6 +378,8 @@ static void vcc_destroy_source(struct source *sp) { + if (sp->freeit != NULL) + free(sp->freeit); free(sp->name); free(sp); } @@ -390,6 +392,7 @@ vcc_file_source(struct vsb *sb, const char *fn, int fd) char *f; int i; struct stat st; + struct source *sp; if (fd < 0) { fd = open(fn, O_RDONLY); @@ -406,7 +409,9 @@ vcc_file_source(struct vsb *sb, const char *fn, int fd) 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); } /*--------------------------------------------------------------------*/ diff --git a/varnish-cache/lib/libvcl/vcc_compile.h b/varnish-cache/lib/libvcl/vcc_compile.h index df4441e8..1ff47e0c 100644 --- a/varnish-cache/lib/libvcl/vcc_compile.h +++ b/varnish-cache/lib/libvcl/vcc_compile.h @@ -45,6 +45,7 @@ struct source { const char *b; const char *e; unsigned idx; + char *freeit; }; struct token {