Fix: leak on agent event listing error
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 29 Aug 2018 21:10:25 +0000 (17:10 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 30 Aug 2018 16:35:13 +0000 (12:35 -0400)
Jumping to the 'error' label after allocating tmp_events results
in a memory leak.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c

index 4ae8a1a35a1ba57d4b2b7e6c364ddff61efe9cb2..53a72d9b8d9129e04faac25ab84d81f214d2babd 100644 (file)
@@ -490,7 +490,7 @@ static int list_lttng_agent_events(struct agent *agt,
        int i = 0, ret = 0;
        unsigned int nb_event = 0;
        struct agent_event *event;
-       struct lttng_event *tmp_events;
+       struct lttng_event *tmp_events = NULL;
        struct lttng_ht_iter iter;
        size_t extended_len = 0;
        void *extended_at;
@@ -562,9 +562,12 @@ static int list_lttng_agent_events(struct agent *agt,
        ret = nb_event;
        assert(nb_event == i);
 
-error:
+end:
        rcu_read_unlock();
        return ret;
+error:
+       free(tmp_events);
+       goto end;
 }
 
 /*
This page took 0.030612 seconds and 5 git commands to generate.