From: Jérémie Galarneau Date: Wed, 10 Apr 2019 20:25:20 +0000 (-0400) Subject: Fix tests: NULL pointer dereference in ltt_ust_context unit tests X-Git-Tag: v2.9.12~7 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=407f377359508ebc0517b1f3db97cb143ae45e7b;p=lttng-tools.git Fix tests: NULL pointer dereference in ltt_ust_context unit tests The check for the expected context's type must be skipped when trace_ust_create_context() fails. Otherwise, a NULL pointer dereference will occur. Signed-off-by: Jérémie Galarneau --- diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c index 7996b8e60..35e1b87a0 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -247,8 +247,12 @@ static void test_create_ust_context(void) uctx = trace_ust_create_context(&ectx); ok(uctx != NULL, "Create UST context"); - ok((int) uctx->ctx.ctx == LTTNG_UST_CONTEXT_VTID, - "Validate UST context"); + if (uctx) { + ok((int) uctx->ctx.ctx == LTTNG_UST_CONTEXT_VTID, + "Validate UST context"); + } else { + skip(1, "Skipping UST context validation as creation failed"); + } free(uctx); }