From d61d06f0e7d348674e8b63e350a04ab852968561 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 10 Apr 2019 16:16:43 -0400 Subject: [PATCH] Fix tests: NULL pointer dereference in ltt_session unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- tests/unit/test_session.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_session.c b/tests/unit/test_session.c index fa3e367d2..991b1dca3 100644 --- a/tests/unit/test_session.c +++ b/tests/unit/test_session.c @@ -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(); } -- 2.34.1