aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/mode.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2016-12-15 17:39:09 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2016-12-15 19:01:40 -0500
commit248df18c24d2a849de984b477ca3913ce7c72441 (patch)
tree35beb85ecfcc54574d3b5e82c8445eb8c1219689 /sway/commands/mode.c
parentHandle border-related malloc failures (diff)
downloadsway-248df18c24d2a849de984b477ca3913ce7c72441.tar.gz
sway-248df18c24d2a849de984b477ca3913ce7c72441.tar.zst
sway-248df18c24d2a849de984b477ca3913ce7c72441.zip
Handle allocation failure in commands
Diffstat (limited to 'sway/commands/mode.c')
-rw-r--r--sway/commands/mode.c5
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) {
30 } 30 }
31 // Create mode if it doesn't exist 31 // Create mode if it doesn't exist
32 if (!mode && mode_make) { 32 if (!mode && mode_make) {
33 mode = malloc(sizeof*mode); 33 mode = malloc(sizeof(struct sway_mode));
34 if (!mode) {
35 return cmd_results_new(CMD_FAILURE, "mode", "Unable to allocate mode");
36 }
34 mode->name = strdup(mode_name); 37 mode->name = strdup(mode_name);
35 mode->bindings = create_list(); 38 mode->bindings = create_list();
36 list_add(config->modes, mode); 39 list_add(config->modes, mode);