aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/liblzma/common/block_header_decoder.c20
-rw-r--r--src/liblzma/common/stream_decoder.c4
-rw-r--r--src/liblzma/common/stream_decoder_mt.c22
3 files changed, 8 insertions, 38 deletions
diff --git a/src/liblzma/common/block_header_decoder.c b/src/liblzma/common/block_header_decoder.c
index 24588c56..9b9408b0 100644
--- a/src/liblzma/common/block_header_decoder.c
+++ b/src/liblzma/common/block_header_decoder.c
@@ -14,22 +14,6 @@
#include "check.h"
-static void
-free_properties(lzma_block *block, const lzma_allocator *allocator)
-{
- // Free allocated filter options. The last array member is not
- // touched after the initialization in the beginning of
- // lzma_block_header_decode(), so we don't need to touch that here.
- for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i) {
- lzma_free(block->filters[i].options, allocator);
- block->filters[i].id = LZMA_VLI_UNKNOWN;
- block->filters[i].options = NULL;
- }
-
- return;
-}
-
-
extern LZMA_API(lzma_ret)
lzma_block_header_decode(lzma_block *block,
const lzma_allocator *allocator, const uint8_t *in)
@@ -107,7 +91,7 @@ lzma_block_header_decode(lzma_block *block,
&block->filters[i], allocator,
in, &in_pos, in_size);
if (ret != LZMA_OK) {
- free_properties(block, allocator);
+ lzma_filters_free(block->filters, allocator);
return ret;
}
}
@@ -115,7 +99,7 @@ lzma_block_header_decode(lzma_block *block,
// Padding
while (in_pos < in_size) {
if (in[in_pos++] != 0x00) {
- free_properties(block, allocator);
+ lzma_filters_free(block->filters, allocator);
// Possibly some new field present so use
// LZMA_OPTIONS_ERROR instead of LZMA_DATA_ERROR.
diff --git a/src/liblzma/common/stream_decoder.c b/src/liblzma/common/stream_decoder.c
index 6885d0c7..dcf7c149 100644
--- a/src/liblzma/common/stream_decoder.c
+++ b/src/liblzma/common/stream_decoder.c
@@ -243,9 +243,7 @@ stream_decode(void *coder_ptr, const lzma_allocator *allocator,
// Free the allocated filter options since they are needed
// only to initialize the Block decoder.
- for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i)
- lzma_free(filters[i].options, allocator);
-
+ lzma_filters_free(filters, allocator);
coder->block_options.filters = NULL;
// Check if memory usage calculation and Block decoder
diff --git a/src/liblzma/common/stream_decoder_mt.c b/src/liblzma/common/stream_decoder_mt.c
index 4413f398..5733c764 100644
--- a/src/liblzma/common/stream_decoder_mt.c
+++ b/src/liblzma/common/stream_decoder_mt.c
@@ -929,18 +929,6 @@ decode_block_header(struct lzma_stream_coder *coder,
}
-static void
-cleanup_filters(lzma_filter *filters, const lzma_allocator *allocator)
-{
- for (uint32_t i = 0; i < LZMA_FILTERS_MAX; ++i) {
- lzma_free(filters[i].options, allocator);
- filters[i].options = NULL;
- }
-
- return;
-}
-
-
/// Get the size of the Compressed Data + Block Padding + Check.
static size_t
comp_blk_size(const struct lzma_stream_coder *coder)
@@ -1481,7 +1469,7 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator,
// Free the allocated filter options since they are needed
// only to initialize the Block decoder.
- cleanup_filters(coder->filters, allocator);
+ lzma_filters_free(coder->filters, allocator);
coder->thr->block_options.filters = NULL;
// Check if memory usage calculation and Block encoder
@@ -1613,7 +1601,7 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator,
// Free the allocated filter options since they are needed
// only to initialize the Block decoder.
- cleanup_filters(coder->filters, allocator);
+ lzma_filters_free(coder->filters, allocator);
coder->block_options.filters = NULL;
// Check if Block decoder initialization succeeded.
@@ -1812,7 +1800,7 @@ stream_decoder_mt_end(void *coder_ptr, const lzma_allocator *allocator)
lzma_outq_end(&coder->outq, allocator);
lzma_next_end(&coder->block_decoder, allocator);
- cleanup_filters(coder->filters, allocator);
+ lzma_filters_free(coder->filters, allocator);
lzma_index_hash_end(coder->index_hash, allocator);
lzma_free(coder, allocator);
@@ -1939,7 +1927,7 @@ stream_decoder_mt_init(lzma_next_coder *next, const lzma_allocator *allocator,
next->memconfig = &stream_decoder_mt_memconfig;
next->get_progress = &stream_decoder_mt_get_progress;
- memzero(coder->filters, sizeof(coder->filters));
+ coder->filters[0].id = LZMA_VLI_UNKNOWN;
memzero(&coder->outq, sizeof(coder->outq));
coder->block_decoder = LZMA_NEXT_CODER_INIT;
@@ -1953,7 +1941,7 @@ stream_decoder_mt_init(lzma_next_coder *next, const lzma_allocator *allocator,
// Cleanup old filter chain if one remains after unfinished decoding
// of a previous Stream.
- cleanup_filters(coder->filters, allocator);
+ lzma_filters_free(coder->filters, allocator);
// By allocating threads from scratch we can start memory-usage
// accounting from scratch, too. Changes in filter and block sizes may