From 9dd7f48b4911cbf35ee1f4ddb4a04a930c7ef4f9 Mon Sep 17 00:00:00 2001 From: Eero Nurkkala Date: Tue, 21 Jul 2020 11:13:01 +0300 Subject: [PATCH] tests: hashmap-test.c: fix memory leak When compiled with ASAN: -O1 -fsanitize=address -fno-omit-frame-pointer, the following issue is seen: ==14272==ERROR: LeakSanitizer: detected memory leaks Direct leak of 1072 byte(s) in 1 object(s) allocated from: #0 0x7f0180966d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) #1 0x7f018039f043 in pa_xmalloc0 pulse/xmalloc.c:74 #2 0x7f01803c5cc8 in pa_hashmap_new_full pulsecore/hashmap.c:61 #3 0x7f01803c5df9 in pa_hashmap_new pulsecore/hashmap.c:76 #4 0x556ee75ff7f4 in remove_all_test tests/hashmap-test.c:96 #5 0x556ee7602965 in srunner_run (/home/eenurkka/pulse/pulseaudio/src/.libs/hashmap-test+0x6965) SUMMARY: AddressSanitizer: 1072 byte(s) leaked in 1 allocation(s). Fix it by freeing the resource properly. Signed-off-by: Eero Nurkkala --- src/tests/hashmap-test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tests/hashmap-test.c b/src/tests/hashmap-test.c index 39d3e8502..f460bd434 100644 --- a/src/tests/hashmap-test.c +++ b/src/tests/hashmap-test.c @@ -108,6 +108,8 @@ START_TEST(remove_all_test) if ((size = pa_hashmap_size(map)) != 0) { ck_abort_msg("Hashmap has wrong size; got %u, want 0", size); } + + pa_hashmap_free(map); } END_TEST