From 77f5299fdcfb59efd50f3340e1e063adcb7dc421 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 10 Apr 2019 16:25:20 -0400 Subject: [PATCH] Fix tests: NULL pointer dereference in ltt_ust_context unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- tests/unit/test_ust_data.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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); } -- 2.34.1