diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-12-15 17:39:09 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-12-15 19:01:40 -0500 |
commit | 248df18c24d2a849de984b477ca3913ce7c72441 (patch) | |
tree | 35beb85ecfcc54574d3b5e82c8445eb8c1219689 /sway/commands/mode.c | |
parent | 8691ff1b63655c6fb11fd2ffe90770e7de707963 (diff) |
Handle allocation failure in commands
Diffstat (limited to 'sway/commands/mode.c')
-rw-r--r-- | sway/commands/mode.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sway/commands/mode.c b/sway/commands/mode.c index f9cb271e..ed3f432f 100644 --- a/sway/commands/mode.c +++ b/sway/commands/mode.c @@ -30,7 +30,10 @@ struct cmd_results *cmd_mode(int argc, char **argv) { } // Create mode if it doesn't exist if (!mode && mode_make) { - mode = malloc(sizeof*mode); + mode = malloc(sizeof(struct sway_mode)); + if (!mode) { + return cmd_results_new(CMD_FAILURE, "mode", "Unable to allocate mode"); + } mode->name = strdup(mode_name); mode->bindings = create_list(); list_add(config->modes, mode); |