From: Adam Dickmeiss Date: Mon, 28 Mar 2011 12:34:36 +0000 (+0200) Subject: Fix memory leak for termlist of type xtargets X-Git-Tag: v1.5.5~1 X-Git-Url: http://git.indexdata.com/?p=pazpar2-moved-to-github.git;a=commitdiff_plain;h=014645e6781e165aa2b4473cd73f21daa93f8076 Fix memory leak for termlist of type xtargets The setting_xml is now a regular string allocated on the NMEM handle that is passed to hitsbytarget anyway. --- diff --git a/src/http_command.c b/src/http_command.c index b3e4dc7..8c21c8c 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -721,11 +721,10 @@ static void cmd_bytarget(struct http_channel *c) if (settings && *settings == '1') { wrbuf_puts(c->wrbuf, "\n"); - wrbuf_puts(c->wrbuf, wrbuf_cstr(ht[i].settings_xml)); + wrbuf_puts(c->wrbuf, ht[i].settings_xml); wrbuf_puts(c->wrbuf, "\n"); } wrbuf_puts(c->wrbuf, ""); - wrbuf_destroy(ht[i].settings_xml); } wrbuf_puts(c->wrbuf, ""); diff --git a/src/session.c b/src/session.c index c0006a5..7b6e78a 100644 --- a/src/session.c +++ b/src/session.c @@ -839,7 +839,8 @@ struct hitsbytarget *hitsbytarget(struct session *se, int *count, NMEM nmem) res[*count].state = client_get_state_str(cl); res[*count].connected = client_get_connection(cl) ? 1 : 0; session_settings_dump(se, client_get_database(cl), w); - res[*count].settings_xml = w; + res[*count].settings_xml = nmem_strdup(nmem, wrbuf_cstr(w)); + wrbuf_destroy(w); (*count)++; } session_leave(se); diff --git a/src/session.h b/src/session.h index 6f43d69..fdecbc4 100644 --- a/src/session.h +++ b/src/session.h @@ -143,7 +143,7 @@ struct hitsbytarget { int records; const char *state; int connected; - WRBUF settings_xml; + char *settings_xml; }; struct hitsbytarget *hitsbytarget(struct session *s, int *count, NMEM nmem);