From: phk Date: Sun, 15 Jul 2007 11:08:48 +0000 (+0000) Subject: Plug even more memory leaks in the VCL compiler. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cda2e888779485a838acee158490bf06a63ddbaf;p=varnish Plug even more memory leaks in the VCL compiler. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1704 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/lib/libvcl/vcc_compile.c b/varnish-cache/lib/libvcl/vcc_compile.c index 440456bf..e2826486 100644 --- a/varnish-cache/lib/libvcl/vcc_compile.c +++ b/varnish-cache/lib/libvcl/vcc_compile.c @@ -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); } diff --git a/varnish-cache/lib/libvcl/vcc_token.c b/varnish-cache/lib/libvcl/vcc_token.c index 80ef0d58..311abd2d 100644 --- a/varnish-cache/lib/libvcl/vcc_token.c +++ b/varnish-cache/lib/libvcl/vcc_token.c @@ -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; ) {