[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Fix memory leak when uncompressing concatenated zlib stream...
Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv14807/src/common
Modified Files:
torgzip.c
Log Message:
Fix memory leak when uncompressing concatenated zlib streams. Unit tests and tor client work; looks ok.
Index: torgzip.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/torgzip.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -p -d -r1.31 -r1.32
--- torgzip.c 20 Mar 2006 02:13:35 -0000 1.31
+++ torgzip.c 21 Mar 2006 20:31:27 -0000 1.32
@@ -205,9 +205,10 @@ tor_gzip_uncompress(char **out, size_t *
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>");