]> err.no Git - varnish/commitdiff
Plug even more memory leaks in the VCL compiler.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 15 Jul 2007 11:08:48 +0000 (11:08 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 15 Jul 2007 11:08:48 +0000 (11:08 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1704 d4fa192b-c00b-0410-8231-f00ffab90ce4

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

index 440456bf468ba428d4430c0886019d1e2907ab8a..e28264864af042790d8d06a90b5945e3e952d6c3 100644 (file)
@@ -514,6 +514,7 @@ static char *
 vcc_DestroyTokenList(struct tokenlist *tl, char *ret)
 {
        struct membit *mb;
+       struct source *sp;
        int i;
 
        while (!TAILQ_EMPTY(&tl->membits)) {
@@ -522,6 +523,11 @@ vcc_DestroyTokenList(struct tokenlist *tl, char *ret)
                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 @@ VCC_Compile(struct vsb *sb, const char *b, const char *e)
        if (sp == NULL)
                return (NULL);
        r = vcc_CompileSource(sb, sp);
-       vcc_destroy_source(sp);
        return (r);
 }
 
@@ -677,7 +682,6 @@ VCC_CompileFile(struct vsb *sb, const char *fn, int fd)
        if (sp == NULL)
                return (NULL);
        r = vcc_CompileSource(sb, sp);
-       vcc_destroy_source(sp);
        return (r);
 }
 
index 80ef0d581d06b97131a5c4c5a042b43cd515e0a0..311abd2d9ed643895ed2a487b7118f63138a03de 100644 (file)
@@ -209,7 +209,7 @@ vcc_decstr(struct tokenlist *tl)
        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; ) {