Fix memleak in lttng list.c
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 7 Feb 2012 03:49:20 +0000 (22:49 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 7 Feb 2012 03:49:20 +0000 (22:49 -0500)
==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 <mathieu.desnoyers@efficios.com>
src/bin/lttng/commands/list.c

index 7c33046ebec1490f798ca4a63e71f0778f91c1db..6040d008d09a7b5f55f06dfdb05f7eb42981bf53 100644 (file)
@@ -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;
 }
 
This page took 0.034595 seconds and 4 git commands to generate.