Skip to content

Commit

Permalink
Fix leak in cmd_ipc
Browse files Browse the repository at this point in the history
  • Loading branch information
JerziKaminsky committed Apr 20, 2017
1 parent 5535d09 commit bfd065d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions sway/commands/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ struct cmd_results *cmd_ipc(int argc, char **argv) {
if ((error = check_security_config())) {
return error;
}

char *program = NULL;

if (!(program = resolve_ipc_path(argv[0]))) {
return cmd_results_new(
CMD_FAILURE, "ipc", "Memory allocation error occured.");
}
if (config->reading && strcmp("{", argv[1]) != 0) {
return cmd_results_new(CMD_INVALID, "ipc",
"Expected '{' at start of IPC config definition.");
Expand All @@ -34,6 +27,12 @@ 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 (!(program = resolve_ipc_path(argv[0]))) {
return cmd_results_new(
CMD_FAILURE, "ipc", "Memory allocation error occured.");
}
current_policy = alloc_ipc_policy(program);
list_add(config->ipc_policies, current_policy);

Expand Down

0 comments on commit bfd065d

Please sign in to comment.