aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-01-15 16:25:38 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-01-15 16:25:38 +0200
commit8235e6e5b2878f76633afcda9a334640db503ef5 (patch)
tree71bd7e078c61fa567fdfbd7d8e1488809b3a4b29 /tests
parentUse fastpos.h when encoding LZMA dictionary size in (diff)
downloadxz-8235e6e5b2878f76633afcda9a334640db503ef5.tar.xz
Fix memory leaks from test_block_header.c.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_block_header.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/test_block_header.c b/tests/test_block_header.c
index 9285a265..b38f4b24 100644
--- a/tests/test_block_header.c
+++ b/tests/test_block_header.c
@@ -62,6 +62,17 @@ static const lzma_options_filter filters_delta[3] = {
};
+static void
+free_decoded_options(void)
+{
+ for (size_t i = 0; i < sizeof(decoded_options.filters)
+ / sizeof(decoded_options.filters[0]); ++i) {
+ free(decoded_options.filters[i].options);
+ decoded_options.filters[i].options = NULL;
+ }
+}
+
+
static bool
encode(uint32_t header_size)
{
@@ -88,7 +99,9 @@ decode_ret(uint32_t header_size, lzma_ret ret_ok)
expect(lzma_block_header_decoder(&strm, &decoded_options) == LZMA_OK);
- return decoder_loop_ret(&strm, buffer, header_size, ret_ok);
+ const bool ret = decoder_loop_ret(&strm, buffer, header_size, ret_ok);
+ free_decoded_options();
+ return ret;
}
@@ -100,7 +113,9 @@ decode(uint32_t header_size)
expect(lzma_block_header_decoder(&strm, &decoded_options) == LZMA_OK);
- if (decoder_loop(&strm, buffer, header_size))
+ const bool ret = decoder_loop(&strm, buffer, header_size);
+ free_decoded_options();
+ if (ret)
return true;
if (known_options.has_eopm != decoded_options.has_eopm)