From de667f2b9733b2a4cc617b35800486c11babc7ae Mon Sep 17 00:00:00 2001 From: Dominik Loidolt <dominik.loidolt@univie.ac.at> Date: Mon, 3 Oct 2022 15:37:06 +0200 Subject: [PATCH] remove some memory leaks --- test/cmp_icu/test_cmp_decmp.c | 8 +++++++- test/cmp_icu/test_cmp_icu.c | 3 +++ test/cmp_icu/test_decmp.c | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/cmp_icu/test_cmp_decmp.c b/test/cmp_icu/test_cmp_decmp.c index 9eb587e..a1ac615 100644 --- a/test/cmp_icu/test_cmp_decmp.c +++ b/test/cmp_icu/test_cmp_decmp.c @@ -493,9 +493,14 @@ void compression_decompression(struct cmp_cfg *cfg) int data_size, cmp_data_size; struct cmp_entity *ent; void *decompressed_data; - static void *model_of_data; + static void *model_of_data = NULL; void *updated_model = NULL; + if (!cfg) { + free(model_of_data); + return; + } + TEST_ASSERT_NOT_NULL(cfg); TEST_ASSERT_NULL(cfg->icu_output_buf); @@ -611,6 +616,7 @@ void test_random_compression_decompression(void) free(data_to_compress2); free(updated_model); } + compression_decompression(NULL); } #define N_SAMPLES 5 diff --git a/test/cmp_icu/test_cmp_icu.c b/test/cmp_icu/test_cmp_icu.c index 65ab545..a1ba7f9 100644 --- a/test/cmp_icu/test_cmp_icu.c +++ b/test/cmp_icu/test_cmp_icu.c @@ -2740,6 +2740,9 @@ void test_compress_s_fx_raw(void) TEST_ASSERT_EQUAL_HEX(data[i].exp_flags, p[i].exp_flags); TEST_ASSERT_EQUAL_HEX(data[i].fx, cpu_to_be32(p[i].fx)); } + + free(cfg.input_buf); + free(cfg.icu_output_buf); } diff --git a/test/cmp_icu/test_decmp.c b/test/cmp_icu/test_decmp.c index 6f2fe2d..e1d7025 100644 --- a/test/cmp_icu/test_decmp.c +++ b/test/cmp_icu/test_decmp.c @@ -437,6 +437,8 @@ void test_cmp_decmp_s_fx_diff(void) /* if (up_model[i] != de_up_model[i]) */ /* TEST_ASSERT(0); */ /* } */ + free(ent); + free(decompressed_data); } #undef DATA_SAMPLES @@ -629,6 +631,7 @@ void test_s_fx_diff(void) for (i = 0; i < s; ++i) { TEST_ASSERT_EQUAL(result_data[i], decompressed_data[i]); } + free(decompressed_data); } -- GitLab