dryang / rpms / systemd

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