richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
dcda24
From 944596e66a9cd947545c714c4682681fdbefc09f Mon Sep 17 00:00:00 2001
dcda24
From: Anita Zhang <the.anitazha@gmail.com>
dcda24
Date: Thu, 17 Sep 2020 01:49:17 -0700
dcda24
Subject: [PATCH] core: move reset_arguments() to the end of main's finish
dcda24
dcda24
Fixes #16991
dcda24
dcda24
fb39af4ce42d7ef9af63009f271f404038703704 replaced `free_arguments()` with
dcda24
`reset_arguments()`, which frees arg_* variables as before, but also resets all
dcda24
of them to the default values. `reset_arguments()` was positioned
dcda24
in such a way that it overrode some arg_* values still in use at shutdown.
dcda24
dcda24
To avoid further unintentional resets, I moved `reset_arguments()`
dcda24
right before the return, when nothing else will be using the arg_* variables.
dcda24
dcda24
(cherry picked from commit 7d9eea2bd3d4f83668c7a78754d201b226acbf1e)
dcda24
dcda24
Resolves: #2127170
dcda24
---
dcda24
 src/core/main.c | 3 ++-
dcda24
 1 file changed, 2 insertions(+), 1 deletion(-)
dcda24
dcda24
diff --git a/src/core/main.c b/src/core/main.c
dcda24
index bfd4c531a7..cfa6fec930 100644
dcda24
--- a/src/core/main.c
dcda24
+++ b/src/core/main.c
dcda24
@@ -2631,7 +2631,6 @@ finish:
dcda24
                 m = manager_free(m);
dcda24
         }
dcda24
 
dcda24
-        reset_arguments();
dcda24
         mac_selinux_finish();
dcda24
 
dcda24
         if (reexecute)
dcda24
@@ -2656,6 +2655,7 @@ finish:
dcda24
                  * in become_shutdown() so normally we cannot free them yet. */
dcda24
                 watchdog_free_device();
dcda24
                 arg_watchdog_device = mfree(arg_watchdog_device);
dcda24
+                reset_arguments();
dcda24
                 return retval;
dcda24
         }
dcda24
 #endif
dcda24
@@ -2677,5 +2677,6 @@ finish:
dcda24
                 freeze_or_reboot();
dcda24
         }
dcda24
 
dcda24
+        reset_arguments();
dcda24
         return retval;
dcda24
 }