aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-03-21 20:31:27 +0000
committerNick Mathewson <nickm@torproject.org>2006-03-21 20:31:27 +0000
commit15e5cf60882f7e9112394b0a3003f4aa9eb31024 (patch)
tree97b4bcaa686d42f2fd529540795d5cc0038862f3 /src
parent68b3b3ee7cf2ca6e7057e1d7cc73e8dcef1b2f95 (diff)
downloadtor-15e5cf60882f7e9112394b0a3003f4aa9eb31024.tar
tor-15e5cf60882f7e9112394b0a3003f4aa9eb31024.tar.gz
Fix memory leak when uncompressing concatenated zlib streams. Unit tests and tor client work; looks ok.
svn:r6211
Diffstat (limited to 'src')
-rw-r--r--src/common/torgzip.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/common/torgzip.c b/src/common/torgzip.c
index 1f78089f6..12cc7ec96 100644
--- a/src/common/torgzip.c
+++ b/src/common/torgzip.c
@@ -205,9 +205,10 @@ tor_gzip_uncompress(char **out, size_t *out_len,
if (stream->avail_in == 0)
goto done;
/* There may be more compressed data here. */
- /* XXX But if so, this is not the right way to find it. If
- * we call inflateInit2 below, stream->state will get
- * re-zcalloc'ed and we'll leak the old one. -RD */
+ if ((r = inflateEnd(stream)) != Z_OK) {
+ log_warn(LD_GENERAL, "Error freeing gzip structures");
+ goto err;
+ }
if (inflateInit2(stream, method_bits(method)) != Z_OK) {
log_warn(LD_GENERAL, "Error from inflateInit2: %s",
stream->msg?stream->msg:"<no message>");