From dd1cd4064dbceb0bb023aa2719427fe8c8b76003 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 43ad3115b..f22f8c4e2 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -252,8 +252,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