Tests: fix: leak of notification-client arguments
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 17 Apr 2021 22:47:16 +0000 (18:47 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 18 Apr 2021 23:28:57 +0000 (19:28 -0400)
Valgrind reports the following leaks:

==334435== HEAP SUMMARY:
==334435==     in use at exit: 8,568 bytes in 24 blocks
==334435==   total heap usage: 846 allocs, 822 frees, 1,425,964 bytes allocated
==334435==
==334435== 9 bytes in 1 blocks are definitely lost in loss record 1 of 11
==334435==    at 0x483E77F: malloc (vg_replace_malloc.c:307)
==334435==    by 0x4BCC5BE: strdup (in /usr/lib/libc-2.33.so)
==334435==    by 0x10A48B: main (notification-client.c:123)
==334435==
==334435== 13 bytes in 1 blocks are definitely lost in loss record 2 of 11
==334435==    at 0x483E77F: malloc (vg_replace_malloc.c:307)
==334435==    by 0x4BCC5BE: strdup (in /usr/lib/libc-2.33.so)
==334435==    by 0x10A473: main (notification-client.c:120)
==334435==
==334435== 27 bytes in 1 blocks are definitely lost in loss record 3 of 11
==334435==    at 0x483E77F: malloc (vg_replace_malloc.c:307)
==334435==    by 0x4BCC5BE: strdup (in /usr/lib/libc-2.33.so)
==334435==    by 0x10A444: main (notification-client.c:114)

Free the strdup()'ed' arguments.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I21523e847141aef50858d3018f37f0125dee0e2c

tests/regression/tools/trigger/utils/notification-client.c

index 904d7e5650c90661bf3dfa524cb837ce266c58c2..54248f6330cca7f3202d6b75f488148685123655 100644 (file)
@@ -98,8 +98,8 @@ int main(int argc, char **argv)
        int ret;
        int option;
        int option_index;
-       const char *expected_trigger_name = NULL;
-       const char *end_trigger_name = NULL;
+       char *expected_trigger_name = NULL;
+       char *end_trigger_name = NULL;
        struct lttng_triggers *triggers = NULL;
        unsigned int count, i, subcription_count = 0;
        enum lttng_trigger_status trigger_status;
@@ -295,5 +295,8 @@ evaluate_success:
 end:
        lttng_triggers_destroy(triggers);
        lttng_notification_channel_destroy(notification_channel);
+       free(after_notif_register_file_path);
+       free(end_trigger_name);
+       free(expected_trigger_name);
        return !!ret;
 }
This page took 0.034684 seconds and 4 git commands to generate.