[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] 2 commits: tests: hashmap-test.c: fix memory leak

Arun Raghavan gitlab at gitlab.freedesktop.org
Tue Jul 21 12:02:08 UTC 2020



Arun Raghavan pushed to branch master at PulseAudio / pulseaudio


Commits:
9dd7f48b by Eero Nurkkala at 2020-07-21T14:56:59+03:00
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 at offcode.fi>

- - - - -
1f1fb8eb by Eero Nurkkala at 2020-07-21T14:57:05+03:00
tests: cpu-remap-test.c: fix memory leaks

When compiled with ASAN: -O1 -fsanitize=address -fno-omit-frame-pointer,
the following issues are seen:

==17217==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7fceba414b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
    #1 0x7fceb9b3eac9 in pa_xmalloc pulse/xmalloc.c:63
    #2 0x7fceb9b3ed22 in pa_xmemdup pulse/xmalloc.c:94
    #3 0x7fceb9e1eed5 in _pa_xnewdup_internal pulse/xmalloc.h:86
    #4 0x7fceb9e1eed5 in init_remap_c pulsecore/remap.c:580
    #5 0x7fceb9e1efe5 in pa_init_remap_func pulsecore/remap.c:608
    #6 0x5574e72422b7 in remap_init2_test_channels tests/cpu-remap-test.c:303
    #7 0x5574e7242420 in rearrange_special_test tests/cpu-remap-test.c:345
    #8 0x5574e7245ce5 in srunner_run (/home/eenurkka/pulse/pulseaudio/src/.libs/cpu-remap-test+0x9ce5)
...
SUMMARY: AddressSanitizer: 192 byte(s) leaked in 6 allocation(s).

Fix those issues by freeing the allocated resources properly.

Signed-off-by: Eero Nurkkala <eero.nurkkala at offcode.fi>

- - - - -


2 changed files:

- src/tests/cpu-remap-test.c
- src/tests/hashmap-test.c


Changes:

=====================================
src/tests/cpu-remap-test.c
=====================================
@@ -26,6 +26,7 @@
 #include <pulsecore/random.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/remap.h>
+#include <pulse/xmalloc.h>
 
 #include "runtime-test-util.h"
 
@@ -290,7 +291,7 @@ static void remap_init2_test_channels(
         bool rearrange) {
 
     pa_cpu_info cpu_info = { PA_CPU_UNDEFINED, {}, false };
-    pa_remap_t remap_orig, remap_func;
+    pa_remap_t remap_orig, remap_func = {0};
 
     cpu_info.force_generic_code = true;
     pa_remap_func_init(&cpu_info);
@@ -303,6 +304,8 @@ static void remap_init2_test_channels(
     pa_init_remap_func(&remap_func);
 
     remap_test_channels(&remap_func, &remap_orig);
+
+    pa_xfree(remap_func.state);
 }
 
 START_TEST (remap_special_test) {


=====================================
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
 



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/5c0ad422a818520337108acd700b1b4744588260...1f1fb8eb6b3e9ce9a6d7b382f48ddb2349d98be6

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/5c0ad422a818520337108acd700b1b4744588260...1f1fb8eb6b3e9ce9a6d7b382f48ddb2349d98be6
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20200721/4c13e03b/attachment-0001.htm>


More information about the pulseaudio-commits mailing list