From: Krzysztof Piotr Oledzki Date: Fri, 5 Feb 2010 19:31:44 +0000 (+0100) Subject: [BUG] cfgparse memory leak and missing free calls in deinit() X-Git-Tag: v1.4.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aff01ea1dcead4736067deb86821c7e0b37c6ac2;p=thirdparty%2Fhaproxy.git [BUG] cfgparse memory leak and missing free calls in deinit() Thich patch fixes cfgparser not to leak memory on each default server statement and adds several missing free calls in deinit(): - free(l->name) - free(l->counters) - free(p->desc); - free(p->fwdfor_hdr_name); None of them are critical, hopefully. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index 0b165e6115..2980ae10de 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -3023,13 +3023,13 @@ stats_error_parsing: goto out; } - if ((newsrv = (struct server *)calloc(1, sizeof(struct server))) == NULL) { - Alert("parsing [%s:%d] : out of memory.\n", file, linenum); - err_code |= ERR_ALERT | ERR_ABORT; - goto out; - } - if (!defsrv) { + if ((newsrv = (struct server *)calloc(1, sizeof(struct server))) == NULL) { + Alert("parsing [%s:%d] : out of memory.\n", file, linenum); + err_code |= ERR_ALERT | ERR_ABORT; + goto out; + } + /* the servers are linked backwards first */ newsrv->next = curproxy->srv; curproxy->srv = newsrv; diff --git a/src/haproxy.c b/src/haproxy.c index c44d46988e..d8c584c5c3 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -854,10 +854,15 @@ void deinit(void) l = p->listen; while (l) { l_next = l->next; + free(l->name); + free(l->counters); free(l); l = l_next; }/* end while(l) */ + free(p->desc); + free(p->fwdfor_hdr_name); + req_acl_free(&p->req_acl); pool_destroy2(p->req_cap_pool);