From 26607d22631d4e06bd6b3dccb60ee9ee4d0ef78e Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Mon, 18 Feb 2008 17:43:34 +0100 Subject: [PATCH] decompress_data: Do not leak memory in mem_realloc. --- src/protocol/http/http.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/protocol/http/http.c b/src/protocol/http/http.c index fc94c9e6..588b01b6 100644 --- a/src/protocol/http/http.c +++ b/src/protocol/http/http.c @@ -1014,6 +1014,8 @@ decompress_data(struct connection *conn, unsigned char *data, int len, } do { + unsigned char *tmp; + if (state == NORMAL) { /* ... we aren't finishing yet. */ int written = safe_write(conn->stream_pipes[1], data, len); @@ -1050,8 +1052,9 @@ decompress_data(struct connection *conn, unsigned char *data, int len, if (!conn->stream) return NULL; } - output = (unsigned char *) mem_realloc(output, *new_len + BIG_READ); - if (!output) break; + tmp = mem_realloc(output, *new_len + BIG_READ); + if (!tmp) break; + output = tmp; did_read = read_encoded(conn->stream, output + *new_len, BIG_READ); -- 2.11.4.GIT