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 <eero.nurkkala@offcode.fi>
This commit is contained in:
Eero Nurkkala 2020-07-21 11:13:01 +03:00
parent 5c0ad422a8
commit 9dd7f48b49

View file

@ -108,6 +108,8 @@ START_TEST(remove_all_test)
if ((size = pa_hashmap_size(map)) != 0) { if ((size = pa_hashmap_size(map)) != 0) {
ck_abort_msg("Hashmap has wrong size; got %u, want 0", size); ck_abort_msg("Hashmap has wrong size; got %u, want 0", size);
} }
pa_hashmap_free(map);
} }
END_TEST END_TEST