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.10.7~9 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=dd1cd4064dbceb0bb023aa2719427fe8c8b76003;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 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); }