]> err.no Git - varnish/commitdiff
Don't leak the file contents either.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 15 Jul 2007 11:04:52 +0000 (11:04 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 15 Jul 2007 11:04:52 +0000 (11:04 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1703 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/lib/libvcl/vcc_compile.c
varnish-cache/lib/libvcl/vcc_compile.h

index 07eca8e2b13b8e0c8c80af9ff0bfb1b082dcb694..440456bf468ba428d4430c0886019d1e2907ab8a 100644 (file)
@@ -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);
 }
 
 /*--------------------------------------------------------------------*/
index df4441e898a3480172e19a91b7a55c2028a91507..1ff47e0ca299268809be7395b7c8f69688e2bf85 100644 (file)
@@ -45,6 +45,7 @@ struct source {
        const char              *b;
        const char              *e;
        unsigned                idx;
+       char                    *freeit;
 };
 
 struct token {