From: Jérémie Galarneau Date: Fri, 31 Aug 2018 17:39:50 +0000 (-0400) Subject: Test fix: leak of exclusions on allocation error X-Git-Tag: v2.11.0-rc1~6 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e196f4f4b3525e73313529bd34b08d5da408923f;p=lttng-tools.git Test fix: leak of exclusions on allocation error Reported-by: Coverity Scan (1395328 Resource leak) Signed-off-by: Jérémie Galarneau --- diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c index 2d31aa4b0..2acf3d906 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -184,7 +184,7 @@ static void test_create_ust_event_exclusion(void) struct lttng_event ev; char *name; char *random_name; - struct lttng_event_exclusion *exclusion; + struct lttng_event_exclusion *exclusion = NULL; struct lttng_event_exclusion *exclusion_copy = NULL; const int exclusion_count = 2; @@ -254,6 +254,7 @@ static void test_create_ust_event_exclusion(void) LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1), LTTNG_SYMBOL_NAME_LEN); ret = trace_ust_create_event(&ev, NULL, NULL, exclusion, false, &event); + exclusion = NULL; ok(ret == LTTNG_OK, "Create UST event with different exclusion names"); if (!event) { @@ -273,6 +274,7 @@ static void test_create_ust_event_exclusion(void) trace_ust_destroy_event(event); end: + free(exclusion); free(exclusion_copy); return; }