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:33:48 +0000 (19:33 -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 43ad3115bcd4ae6a4a52616f4b2deefb89a429ce..f22f8c4e21fdfcf3db85e9f6a3c8aec161d9cdb3 100644 (file)
@@ -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);
 }
 
This page took 0.02543 seconds and 4 git commands to generate.