summaryrefslogtreecommitdiffstats
path: root/source/a/elogind/5d16d94aa9a5e3afe5b51f591497149630763b24.patch
blob: fe7940fffbbaa1f98248f4f953826928fec062f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From 5d16d94aa9a5e3afe5b51f591497149630763b24 Mon Sep 17 00:00:00 2001
From: Sven Eden <sven@eden-worx.com>
Date: Mon, 22 Apr 2024 08:31:30 +0200
Subject: [PATCH] SIGCHLD handler: Check sleep_fork_action against NULL

Signed-off-by: Sven Eden <sven@eden-worx.com>
---
 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 */
                         }
                 }