aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-01-16 14:48:04 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-01-16 14:48:04 +0200
commit7599bb7064ccf007f054595dedda7927af868252 (patch)
treed925c13e391e42529f8e73b2f4222451ce55790a /src/liblzma
parentAdded memory leak detection to lzmadec.c. (diff)
downloadxz-7599bb7064ccf007f054595dedda7927af868252.tar.xz
Plugged a memory leak in stream_decoder.c.
Diffstat (limited to 'src/liblzma')
-rw-r--r--src/liblzma/common/stream_decoder.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/liblzma/common/stream_decoder.c b/src/liblzma/common/stream_decoder.c
index 75228888..56de3d9f 100644
--- a/src/liblzma/common/stream_decoder.c
+++ b/src/liblzma/common/stream_decoder.c
@@ -204,6 +204,14 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
coder->block_options.check = coder->header_flags.check;
coder->block_options.has_crc32 = coder->header_flags.has_crc32;
+ for (size_t i = 0;
+ i < ARRAY_SIZE(coder->block_options.filters);
+ ++i) {
+ lzma_free(coder->block_options.filters[i].options,
+ allocator);
+ coder->block_options.filters[i].options = NULL;
+ }
+
return_if_error(lzma_block_header_decoder_init(
&coder->block_header_decoder, allocator,
&coder->block_options));
@@ -359,6 +367,9 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
static void
stream_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
{
+ for (size_t i = 0; i < ARRAY_SIZE(coder->block_options.filters); ++i)
+ lzma_free(coder->block_options.filters[i].options, allocator);
+
lzma_next_coder_end(&coder->block_decoder, allocator);
lzma_next_coder_end(&coder->block_header_decoder, allocator);
lzma_next_coder_end(&coder->flags_decoder, allocator);
@@ -389,6 +400,11 @@ stream_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
next->coder->metadata.index = NULL;
next->coder->metadata.extra = NULL;
} else {
+ for (size_t i = 0; i < ARRAY_SIZE(
+ next->coder->block_options.filters); ++i)
+ lzma_free(next->coder->block_options
+ .filters[i].options, allocator);
+
lzma_index_free(next->coder->metadata.index, allocator);
next->coder->metadata.index = NULL;
@@ -396,6 +412,10 @@ stream_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
next->coder->metadata.extra = NULL;
}
+ for (size_t i = 0; i < ARRAY_SIZE(next->coder->block_options.filters);
+ ++i)
+ next->coder->block_options.filters[i].options = NULL;
+
next->coder->info = lzma_info_init(next->coder->info, allocator);
if (next->coder->info == NULL)
return LZMA_MEM_ERROR;