From 014645e6781e165aa2b4473cd73f21daa93f8076 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 28 Mar 2011 14:34:36 +0200 Subject: [PATCH] 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. --- src/http_command.c | 3 +-- src/session.c | 3 ++- src/session.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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); -- 1.7.10.4