From 5d16d94aa9a5e3afe5b51f591497149630763b24 Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Mon, 22 Apr 2024 08:31:30 +0200 Subject: [PATCH] SIGCHLD handler: Check sleep_fork_action against NULL Signed-off-by: Sven Eden --- src/login/elogind.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/login/elogind.c b/src/login/elogind.c index e616b8088e..b47540352f 100644 --- a/src/login/elogind.c +++ b/src/login/elogind.c @@ -81,6 +81,7 @@ static int elogind_sigchld_handler( sd_event_source* s, const struct signalfd_siginfo* si, void* userdata ) { + const HandleActionData* a; Manager* m = userdata; int r, status; @@ -97,13 +98,14 @@ static int elogind_sigchld_handler( /* The sleep forker PID is always "the outer one", so wait for it second. */ if ( m->sleep_fork_pid > 0 ) { + a = m->sleep_fork_action; waitpid(m->sleep_fork_pid, &status, WNOHANG | WUNTRACED); log_debug_elogind( "sleep_fork PID %d waitpid() set status %d", m->sleep_fork_pid, status ); if ( WIFEXITED(status) || WIFSIGNALED(status) ) m->sleep_fork_pid = 0; /* Tell people that they now may take a lock again */ - if ( m->sleep_fork_action->sleep_operation != _SLEEP_OPERATION_INVALID ) { - (void) send_prepare_for( m, m->sleep_fork_action, false ); + if ( a && a->sleep_operation != _SLEEP_OPERATION_INVALID ) { + (void) send_prepare_for( m, a, false ); m->sleep_fork_action = NULL; /* All done */ } }