From: Jérémie Galarneau Date: Wed, 10 Apr 2019 20:16:43 +0000 (-0400) Subject: Fix tests: NULL pointer dereference in ltt_session unit tests X-Git-Tag: v2.11.0-rc2~32 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=21bba73bcee011f677bdb23ec7f95bd2de9e340d;p=lttng-tools.git Fix tests: NULL pointer dereference in ltt_session unit tests 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 --- 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(); }