exec: fix validation during config reload

Split cmd_exec_always into separate methods for general validation and
process creation. This fixes a potential call of join_args with 0 arguments.
This commit is contained in:
Konstantin Pospelov 2020-08-23 13:59:22 +02:00 committed by Simon Ser
parent 6991ac8c70
commit fd216b3a81
3 changed files with 27 additions and 6 deletions

View file

@ -5,12 +5,15 @@
#include "stringop.h"
struct cmd_results *cmd_exec(int argc, char **argv) {
if (!config->active) return cmd_results_new(CMD_DEFER, NULL);
struct cmd_results *error = NULL;
if ((error = cmd_exec_validate(argc, argv))) {
return error;
}
if (config->reloading) {
char *args = join_args(argv, argc);
sway_log(SWAY_DEBUG, "Ignoring 'exec %s' due to reload", args);
free(args);
return cmd_results_new(CMD_SUCCESS, NULL);
}
return cmd_exec_always(argc, argv);
return cmd_exec_process(argc, argv);
}