From 248df18c24d2a849de984b477ca3913ce7c72441 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 15 Dec 2016 17:39:09 -0500 Subject: Handle allocation failure in commands --- sway/commands/set.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sway/commands/set.c') diff --git a/sway/commands/set.c b/sway/commands/set.c index 1f324951..8b293825 100644 --- a/sway/commands/set.c +++ b/sway/commands/set.c @@ -47,6 +47,9 @@ struct cmd_results *cmd_set(int argc, char **argv) { free(var->value); } else { var = malloc(sizeof(struct sway_variable)); + if (!var) { + return cmd_results_new(CMD_FAILURE, "set", "Unable to allocate variable"); + } var->name = strdup(argv[0]); list_add(config->symbols, var); list_qsort(config->symbols, compare_set_qsort); -- cgit v1.2.3