소스 검색

Fix memory leak when uncompressing concatenated zlib streams. Unit tests and tor client work; looks ok.

svn:r6211
Nick Mathewson 19 년 전
부모
커밋
15e5cf6088
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      src/common/torgzip.c

+ 4 - 3
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>");