From cae2172357067e2de34a829d5de616547b680bea Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 31 Mar 2008 11:47:15 +0000 Subject: [PATCH] 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 --- varnish-cache/bin/varnishd/cache_vary.c | 11 +++++++---- varnish-cache/bin/varnishd/mgt_vcc.c | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) 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); } -- 2.39.5