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