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.12.0-rc1~616 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=77f5299fdcfb59efd50f3340e1e063adcb7dc421 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 cea322d32..61e2c3c6e 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -277,8 +277,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); }