aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/mode.c
diff options
context:
space:
mode:
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) {
}
// 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);