]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: move reset_arguments() to the end of main's finish
authorAnita Zhang <the.anitazha@gmail.com>
Thu, 17 Sep 2020 08:49:17 +0000 (01:49 -0700)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 28 Sep 2020 10:39:30 +0000 (12:39 +0200)
Fixes #16991

fb39af4ce42d7ef9af63009f271f404038703704 replaced `free_arguments()` with
`reset_arguments()`, which frees arg_* variables as before, but also resets all
of them to the default values. `reset_arguments()` was positioned
in such a way that it overrode some arg_* values still in use at shutdown.

To avoid further unintentional resets, I moved `reset_arguments()`
right before the return, when nothing else will be using the arg_* variables.

src/core/main.c

index 51e04dab43b433e59366069d87ffd324fe7ab99c..f957217eaaa1ce07417daea8c24d2feff6b8aacb 100644 (file)
@@ -2868,7 +2868,6 @@ finish:
                 m = manager_free(m);
         }
 
-        reset_arguments();
         mac_selinux_finish();
 
         if (reexecute)
@@ -2895,6 +2894,7 @@ finish:
                  * in become_shutdown() so normally we cannot free them yet. */
                 watchdog_free_device();
                 arg_watchdog_device = mfree(arg_watchdog_device);
+                reset_arguments();
                 return retval;
         }
 #endif
@@ -2920,5 +2920,6 @@ finish:
                 freeze_or_exit_or_reboot();
         }
 
+        reset_arguments();
         return retval;
 }