[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.
This commit is contained in:
Krzysztof Piotr Oledzki 2010-02-05 20:31:44 +01:00 committed by Willy Tarreau
parent 7d38afb4a8
commit aff01ea1dc
2 changed files with 11 additions and 6 deletions

View File

@ -3023,13 +3023,13 @@ stats_error_parsing:
goto out; goto out;
} }
if (!defsrv) {
if ((newsrv = (struct server *)calloc(1, sizeof(struct server))) == NULL) { if ((newsrv = (struct server *)calloc(1, sizeof(struct server))) == NULL) {
Alert("parsing [%s:%d] : out of memory.\n", file, linenum); Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
err_code |= ERR_ALERT | ERR_ABORT; err_code |= ERR_ALERT | ERR_ABORT;
goto out; goto out;
} }
if (!defsrv) {
/* the servers are linked backwards first */ /* the servers are linked backwards first */
newsrv->next = curproxy->srv; newsrv->next = curproxy->srv;
curproxy->srv = newsrv; curproxy->srv = newsrv;

View File

@ -854,10 +854,15 @@ void deinit(void)
l = p->listen; l = p->listen;
while (l) { while (l) {
l_next = l->next; l_next = l->next;
free(l->name);
free(l->counters);
free(l); free(l);
l = l_next; l = l_next;
}/* end while(l) */ }/* end while(l) */
free(p->desc);
free(p->fwdfor_hdr_name);
req_acl_free(&p->req_acl); req_acl_free(&p->req_acl);
pool_destroy2(p->req_cap_pool); pool_destroy2(p->req_cap_pool);