From: phk Date: Mon, 31 Mar 2008 11:47:15 +0000 (+0000) Subject: Fix three memory leaks related to vsb's not being vsb_deleted: X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cae2172357067e2de34a829d5de616547b680bea;p=varnish Fix three memory leaks related to vsb's not being vsb_deleted: Two really bad ones in Vary processing, found by Arjan (noosius). One isignificant one related to -b arguments being wrong, found by FlexeLint after I taught it how to spot this kind of issue. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2613 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_vary.c b/varnish-cache/bin/varnishd/cache_vary.c index 94eea721..2ad32742 100644 --- a/varnish-cache/bin/varnishd/cache_vary.c +++ b/varnish-cache/bin/varnishd/cache_vary.c @@ -69,6 +69,10 @@ VRY_Create(const struct sess *sp) struct vsb *sb, *sbh; unsigned l; + /* No Vary: header, no worries */ + if (!http_GetHdr(sp->obj->http, H_Vary, &v)) + return; + /* For vary matching string */ sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); AN(sb); @@ -77,10 +81,6 @@ VRY_Create(const struct sess *sp) sbh = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); AN(sbh); - /* No Vary: header, no worries */ - if (!http_GetHdr(sp->obj->http, H_Vary, &v)) - return; - for (p = v; *p; p++) { /* Find next header-name */ @@ -130,6 +130,9 @@ VRY_Create(const struct sess *sp) sp->obj->vary = malloc(l); AN(sp->obj->vary); memcpy(sp->obj->vary, vsb_data(sb), l); + + vsb_delete(sb); + vsb_delete(sbh); } int diff --git a/varnish-cache/bin/varnishd/mgt_vcc.c b/varnish-cache/bin/varnishd/mgt_vcc.c index e912fecc..d513d757 100644 --- a/varnish-cache/bin/varnishd/mgt_vcc.c +++ b/varnish-cache/bin/varnishd/mgt_vcc.c @@ -423,6 +423,7 @@ mgt_vcc_default(const char *b_arg, const char *f_arg, int f_fd, int C_flag) */ free(port); fprintf(stderr, "invalid backend address\n"); + vsb_delete(sb); return (1); }