From 04c222119033a5f64410c8f7a9737b7f293e9f4e Mon Sep 17 00:00:00 2001 From: Jerzi Kaminsky Date: Fri, 21 Apr 2017 14:01:38 +0300 Subject: [PATCH] Fix leak in cmd_ipc --- sway/commands/ipc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sway/commands/ipc.c b/sway/commands/ipc.c index f0b3035a..eacf7e94 100644 --- a/sway/commands/ipc.c +++ b/sway/commands/ipc.c @@ -19,14 +19,6 @@ struct cmd_results *cmd_ipc(int argc, char **argv) { return error; } - char *program = NULL; - - if (!strcmp(argv[0], "*")) { - program = strdup(argv[0]); - } else if (!(program = resolve_path(argv[0]))) { - return cmd_results_new( - CMD_INVALID, "ipc", "Unable to resolve IPC Policy target."); - } if (config->reading && strcmp("{", argv[1]) != 0) { return cmd_results_new(CMD_INVALID, "ipc", "Expected '{' at start of IPC config definition."); @@ -36,6 +28,14 @@ struct cmd_results *cmd_ipc(int argc, char **argv) { return cmd_results_new(CMD_FAILURE, "ipc", "Can only be used in config file."); } + char *program = NULL; + + if (!strcmp(argv[0], "*")) { + program = strdup(argv[0]); + } else if (!(program = resolve_path(argv[0]))) { + return cmd_results_new( + CMD_INVALID, "ipc", "Unable to resolve IPC Policy target."); + } current_policy = alloc_ipc_policy(program); list_add(config->ipc_policies, current_policy);