From 02dfa15d30d4f780e3222a795f1cfc624e9ae35f Mon Sep 17 00:00:00 2001 From: Jerzi Kaminsky Date: Fri, 21 Apr 2017 02:17:55 +0300 Subject: [PATCH] Fix NULL deref in cmd_ipc --- sway/commands/ipc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sway/commands/ipc.c b/sway/commands/ipc.c index efcfad56..e3e62b42 100644 --- a/sway/commands/ipc.c +++ b/sway/commands/ipc.c @@ -32,8 +32,12 @@ struct cmd_results *cmd_ipc(int argc, char **argv) { return cmd_results_new( CMD_FAILURE, "ipc", "Memory allocation error occured."); } - current_policy = alloc_ipc_policy(program); - list_add(config->ipc_policies, current_policy); + if ((current_policy = alloc_ipc_policy(program))) { + list_add(config->ipc_policies, current_policy); + } else { + return cmd_results_new( + CMD_FAILURE, "ipc", "Failed to allocate security policy."); + } free(program); return cmd_results_new(CMD_BLOCK_IPC, NULL, NULL);