mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
systemctl: allocate arg_wall only on the heap
Previously, we'd allocate it sometimes from the heap, but otherwise let it point directly int argv[]. Let's clean this up, so that we know exactly how to release its resources, and do so at the end.
This commit is contained in:
parent
fc2ffaf17d
commit
172d7abfea
@ -6835,6 +6835,7 @@ static int shutdown_parse_argv(int argc, char *argv[]) {
|
|||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char **wall = NULL;
|
||||||
int c, r;
|
int c, r;
|
||||||
|
|
||||||
assert(argc >= 0);
|
assert(argc >= 0);
|
||||||
@ -6908,10 +6909,16 @@ static int shutdown_parse_argv(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (argc > optind && arg_action == ACTION_CANCEL_SHUTDOWN)
|
if (argc > optind && arg_action == ACTION_CANCEL_SHUTDOWN)
|
||||||
/* No time argument for shutdown cancel */
|
/* No time argument for shutdown cancel */
|
||||||
arg_wall = argv + optind;
|
wall = argv + optind;
|
||||||
else if (argc > optind + 1)
|
else if (argc > optind + 1)
|
||||||
/* We skip the time argument */
|
/* We skip the time argument */
|
||||||
arg_wall = argv + optind + 1;
|
wall = argv + optind + 1;
|
||||||
|
|
||||||
|
if (wall) {
|
||||||
|
arg_wall = strv_copy(wall);
|
||||||
|
if (!arg_wall)
|
||||||
|
return log_oom();
|
||||||
|
}
|
||||||
|
|
||||||
optind = argc;
|
optind = argc;
|
||||||
|
|
||||||
@ -7639,6 +7646,8 @@ finish:
|
|||||||
strv_free(arg_states);
|
strv_free(arg_states);
|
||||||
strv_free(arg_properties);
|
strv_free(arg_properties);
|
||||||
|
|
||||||
|
strv_free(arg_wall);
|
||||||
|
|
||||||
sd_bus_default_flush_close();
|
sd_bus_default_flush_close();
|
||||||
|
|
||||||
return r < 0 ? EXIT_FAILURE : r;
|
return r < 0 ? EXIT_FAILURE : r;
|
||||||
|
Loading…
Reference in New Issue
Block a user