richardphibel / rpms / systemd

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