systemctl: use free_and_replace on global variable

In normal usage we cannot set it multiple times, but from a fuzzer we
may. Doing it this way is nicer anyway.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-02-16 17:15:11 +01:00
parent fd421c4adc
commit 36556f6e51
2 changed files with 5 additions and 4 deletions
+3 -2
View File
@@ -132,9 +132,10 @@ int shutdown_parse_argv(int argc, char *argv[]) {
wall = argv + optind + 1;
if (wall) {
arg_wall = strv_copy(wall);
if (!arg_wall)
char **copy = strv_copy(wall);
if (!copy)
return log_oom();
strv_free_and_replace(arg_wall, copy);
}
optind = argc;
+2 -2
View File
@@ -1159,8 +1159,8 @@ static int run(int argc, char *argv[]) {
case ACTION_SUSPEND_THEN_HIBERNATE:
case ACTION_EMERGENCY:
case ACTION_DEFAULT:
/* systemctl verbs with no equivalent in the legacy commands. These cannot appear in
* arg_action. Fall through. */
/* systemctl verbs with no equivalent in the legacy commands. These cannot appear in
* arg_action. Fall through. */
case _ACTION_INVALID:
default: