Fix tests: NULL pointer dereference in ltt_session unit tests
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 10 Apr 2019 20:16:43 +0000 (16:16 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 24 Apr 2019 23:30:47 +0000 (19:30 -0400)
The check for a NULL kernel session must be skipped when
the session_find_by_name() fails to find a session else a NULL
pointer dereference will occur.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/unit/test_session.c

index fa3e367d20b121f5a7da4dfbb8e73a041d483eaf..991b1dca3de4e71d69d038bab9469bbef402af6c 100644 (file)
@@ -243,13 +243,19 @@ void test_validate_session(void)
        ok(tmp != NULL,
           "Validating session: session found");
 
-       ok(tmp->kernel_session == NULL &&
-          strlen(tmp->name),
-          "Validating session: basic sanity check");
+       if (tmp) {
+               ok(tmp->kernel_session == NULL &&
+                  strlen(tmp->name),
+                  "Validating session: basic sanity check");
+       } else {
+               skip(1, "Skipping session validation check as session was not found");
+               goto end;
+       }
 
        session_lock(tmp);
        session_unlock(tmp);
        session_put(tmp);
+end:
        session_unlock_list();
 }
 
This page took 0.025549 seconds and 4 git commands to generate.