From: Mathieu Desnoyers Date: Tue, 7 Feb 2012 03:49:20 +0000 (-0500) Subject: Fix memleak in lttng list.c X-Git-Tag: v2.0-pre20~13 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ef021732eab101776844ec263468004e287fe6e2;p=lttng-tools.git Fix memleak in lttng list.c ==26825== 580 bytes in 1 blocks are definitely lost in loss record 13 of 13 ==26825== at 0x4C2779D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==26825== by 0x4E2F702: lttng_create_handle (lttng-ctl.c:385) ==26825== by 0x403A5F: cmd_list (list.c:255) ==26825== by 0x40217C: main (lttng.c:266) Signed-off-by: Mathieu Desnoyers --- diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 7c33046eb..6040d008d 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -260,6 +260,7 @@ static int list_ust_events(void) size = lttng_list_tracepoints(handle, &event_list); if (size < 0) { ERR("Unable to list UST events"); + lttng_destroy_handle(handle); return size; } @@ -280,10 +281,12 @@ static int list_ust_events(void) MSG(""); free(event_list); + lttng_destroy_handle(handle); return CMD_SUCCESS; error: + lttng_destroy_handle(handle); return -1; } @@ -311,6 +314,7 @@ static int list_kernel_events(void) size = lttng_list_tracepoints(handle, &event_list); if (size < 0) { ERR("Unable to list kernel events"); + lttng_destroy_handle(handle); return size; } @@ -324,9 +328,11 @@ static int list_kernel_events(void) free(event_list); + lttng_destroy_handle(handle); return CMD_SUCCESS; error: + lttng_destroy_handle(handle); return -1; }