bzip2: plug memory leak on every processed file
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 30 Dec 2010 03:43:35 +0000 (04:43 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 30 Dec 2010 03:43:35 +0000 (04:43 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
archival/bzip2.c
archival/libarchive/bz/bzlib.c

index a6abc931c114c069c89a65fe523e490eb2cf6c8b..ab08ffc1a91e1229591d5a9e423fa2ec4ce1dd3c 100644 (file)
@@ -128,10 +128,12 @@ IF_DESKTOP(long long) int FAST_FUNC compressStream(unpack_info_t *info UNUSED_PA
                        break;
        }
 
-#if ENABLE_FEATURE_CLEAN_UP
+       /* Can't be conditional on ENABLE_FEATURE_CLEAN_UP -
+        * we are called repeatedly
+        */
        BZ2_bzCompressEnd(strm);
        free(iobuf);
-#endif
+
        return total;
 }
 
index b3beeabed83e7c6e5d9f8f91829f839406636392..5f7db747aecf2a2f852cb63d2ec7f6db116659a6 100644 (file)
@@ -361,7 +361,6 @@ int BZ2_bzCompress(bz_stream *strm, int action)
 
 
 /*---------------------------------------------------*/
-#if ENABLE_FEATURE_CLEAN_UP
 static
 void BZ2_bzCompressEnd(bz_stream *strm)
 {
@@ -372,9 +371,8 @@ void BZ2_bzCompressEnd(bz_stream *strm)
        free(s->arr2);
        free(s->ftab);
        free(s->crc32table);
-       free(strm->state);
+       free(s);
 }
-#endif
 
 
 /*---------------------------------------------------*/