Commit 6722457b authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Plug a memory-leak in the VCL compiler.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1700 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 19540075
...@@ -95,18 +95,26 @@ static const char *vcc_default_vcl_b, *vcc_default_vcl_e; ...@@ -95,18 +95,26 @@ static const char *vcc_default_vcl_b, *vcc_default_vcl_e;
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
void * void
TlAlloc(struct tokenlist *tl, unsigned len) TlFree(struct tokenlist *tl, void *p)
{ {
struct membit *mb; struct membit *mb;
void *p;
p = calloc(len, 1);
assert(p != NULL);
mb = calloc(sizeof *mb, 1); mb = calloc(sizeof *mb, 1);
assert(mb != NULL); assert(mb != NULL);
mb->ptr = p; mb->ptr = p;
TAILQ_INSERT_TAIL(&tl->membits, mb, list); TAILQ_INSERT_TAIL(&tl->membits, mb, list);
}
void *
TlAlloc(struct tokenlist *tl, unsigned len)
{
void *p;
p = calloc(len, 1);
assert(p != NULL);
TlFree(tl, p);
return (p); return (p);
} }
......
...@@ -153,6 +153,7 @@ void Fi(const struct tokenlist *tl, int indent, const char *fmt, ...); ...@@ -153,6 +153,7 @@ void Fi(const struct tokenlist *tl, int indent, const char *fmt, ...);
void Ff(const struct tokenlist *tl, int indent, const char *fmt, ...); void Ff(const struct tokenlist *tl, int indent, const char *fmt, ...);
void EncToken(struct vsb *sb, const struct token *t); void EncToken(struct vsb *sb, const struct token *t);
int IsMethod(const struct token *t); int IsMethod(const struct token *t);
void TlFree(struct tokenlist *tl, void *p);
void *TlAlloc(struct tokenlist *tl, unsigned len); void *TlAlloc(struct tokenlist *tl, unsigned len);
/* vcc_obj.c */ /* vcc_obj.c */
......
...@@ -64,10 +64,12 @@ HeaderVar(struct tokenlist *tl, const struct token *t, const struct var *vh) ...@@ -64,10 +64,12 @@ HeaderVar(struct tokenlist *tl, const struct token *t, const struct var *vh)
asprintf(&p, "VRT_GetHdr(sp, %s, \"\\%03o%s:\")", v->hdr, asprintf(&p, "VRT_GetHdr(sp, %s, \"\\%03o%s:\")", v->hdr,
(unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len); (unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len);
AN(p); AN(p);
TlFree(tl, p);
v->rname = p; v->rname = p;
asprintf(&p, "VRT_SetHdr(sp, %s, \"\\%03o%s:\", ", v->hdr, asprintf(&p, "VRT_SetHdr(sp, %s, \"\\%03o%s:\", ", v->hdr,
(unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len); (unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len);
AN(p); AN(p);
TlFree(tl, p);
v->lname = p; v->lname = p;
return (v); return (v);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment