r1700 - trunk/varnish-cache/lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Sun Jul 15 12:22:39 CEST 2007
Author: phk
Date: 2007-07-15 12:22:39 +0200 (Sun, 15 Jul 2007)
New Revision: 1700
Modified:
trunk/varnish-cache/lib/libvcl/vcc_compile.c
trunk/varnish-cache/lib/libvcl/vcc_compile.h
trunk/varnish-cache/lib/libvcl/vcc_var.c
Log:
Plug a memory-leak in the VCL compiler.
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-07-15 10:22:05 UTC (rev 1699)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-07-15 10:22:39 UTC (rev 1700)
@@ -95,18 +95,26 @@
/*--------------------------------------------------------------------*/
+void
+TlFree(struct tokenlist *tl, void *p)
+{
+ struct membit *mb;
+
+ mb = calloc(sizeof *mb, 1);
+ assert(mb != NULL);
+ mb->ptr = p;
+ TAILQ_INSERT_TAIL(&tl->membits, mb, list);
+}
+
+
void *
TlAlloc(struct tokenlist *tl, unsigned len)
{
- struct membit *mb;
void *p;
p = calloc(len, 1);
assert(p != NULL);
- mb = calloc(sizeof *mb, 1);
- assert(mb != NULL);
- mb->ptr = p;
- TAILQ_INSERT_TAIL(&tl->membits, mb, list);
+ TlFree(tl, p);
return (p);
}
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h 2007-07-15 10:22:05 UTC (rev 1699)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h 2007-07-15 10:22:39 UTC (rev 1700)
@@ -153,6 +153,7 @@
void Ff(const struct tokenlist *tl, int indent, const char *fmt, ...);
void EncToken(struct vsb *sb, const struct token *t);
int IsMethod(const struct token *t);
+void TlFree(struct tokenlist *tl, void *p);
void *TlAlloc(struct tokenlist *tl, unsigned len);
/* vcc_obj.c */
Modified: trunk/varnish-cache/lib/libvcl/vcc_var.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_var.c 2007-07-15 10:22:05 UTC (rev 1699)
+++ trunk/varnish-cache/lib/libvcl/vcc_var.c 2007-07-15 10:22:39 UTC (rev 1700)
@@ -64,10 +64,12 @@
asprintf(&p, "VRT_GetHdr(sp, %s, \"\\%03o%s:\")", v->hdr,
(unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len);
AN(p);
+ TlFree(tl, p);
v->rname = p;
asprintf(&p, "VRT_SetHdr(sp, %s, \"\\%03o%s:\", ", v->hdr,
(unsigned)(strlen(v->name + vh->len) + 1), v->name + vh->len);
AN(p);
+ TlFree(tl, p);
v->lname = p;
return (v);
}
More information about the varnish-commit
mailing list