Fix tests: NULL pointer dereference in ltt_ust_context unit tests
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 10 Apr 2019 20:25:20 +0000 (16:25 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 24 Apr 2019 23:36:03 +0000 (19:36 -0400)
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 <jeremie.galarneau@efficios.com>
tests/unit/test_ust_data.c

index 7996b8e60e7d4e9ce60cea4220e44a357692d6ce..35e1b87a03dceb00886bc0c8c076d0810a007b9a 100644 (file)
@@ -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);
 }
 
This page took 0.025159 seconds and 4 git commands to generate.