]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: use ASSERT_PTR to validate result before use
authorLuca Boccassi <bluca@debian.org>
Sat, 9 Dec 2023 13:04:51 +0000 (13:04 +0000)
committerLuca Boccassi <bluca@debian.org>
Sat, 9 Dec 2023 13:17:02 +0000 (13:17 +0000)
handle_action_lookup() in general can return NULL, but not
here as the handle is checked before, so add an assert.

CID#1529415
CID#1529416

src/login/logind-action.c

index b9cb9b818dcc7e3bab3bec167d23966806e0404a..e8951073788e88753cf78ceb9a88c95ec2b70851 100644 (file)
@@ -169,7 +169,7 @@ HandleAction handle_action_sleep_select(HandleActionSleepMask mask) {
                 if (!FLAGS_SET(mask, a))
                         continue;
 
-                if (sleep_supported(handle_action_lookup(*i)->sleep_operation) > 0)
+                if (sleep_supported(ASSERT_PTR(handle_action_lookup(*i))->sleep_operation) > 0)
                         return *i;
         }
 
@@ -213,7 +213,7 @@ static int handle_action_execute(
                                        inhibit_what_to_string(m->delayed_action->inhibit_what),
                                        handle_action_to_string(handle));
 
-        inhibit_operation = handle_action_lookup(handle)->inhibit_what;
+        inhibit_operation = ASSERT_PTR(handle_action_lookup(handle))->inhibit_what;
 
         /* If the actual operation is inhibited, warn and fail */
         if (inhibit_what_is_valid(inhibit_operation) &&