diff options
Diffstat (limited to 'sway/commands/bind.c')
-rw-r--r-- | sway/commands/bind.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c index e8bb3ee8..8282277b 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c | |||
@@ -16,6 +16,10 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) { | |||
16 | } | 16 | } |
17 | 17 | ||
18 | struct sway_binding *binding = malloc(sizeof(struct sway_binding)); | 18 | struct sway_binding *binding = malloc(sizeof(struct sway_binding)); |
19 | if (!binding) { | ||
20 | return cmd_results_new(CMD_FAILURE, "bindsym", | ||
21 | "Unable to allocate binding"); | ||
22 | } | ||
19 | binding->keys = create_list(); | 23 | binding->keys = create_list(); |
20 | binding->modifiers = 0; | 24 | binding->modifiers = 0; |
21 | binding->release = false; | 25 | binding->release = false; |
@@ -46,14 +50,21 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) { | |||
46 | continue; | 50 | continue; |
47 | } | 51 | } |
48 | // Check for xkb key | 52 | // Check for xkb key |
49 | xkb_keysym_t sym = xkb_keysym_from_name(split->items[i], XKB_KEYSYM_CASE_INSENSITIVE); | 53 | xkb_keysym_t sym = xkb_keysym_from_name(split->items[i], |
54 | XKB_KEYSYM_CASE_INSENSITIVE); | ||
50 | if (!sym) { | 55 | if (!sym) { |
51 | error = cmd_results_new(CMD_INVALID, "bindsym", "Unknown key '%s'", (char *)split->items[i]); | ||
52 | free_sway_binding(binding); | 56 | free_sway_binding(binding); |
53 | list_free(split); | 57 | free_flat_list(split); |
54 | return error; | 58 | return cmd_results_new(CMD_INVALID, "bindsym", "Unknown key '%s'", |
59 | (char *)split->items[i]); | ||
55 | } | 60 | } |
56 | xkb_keysym_t *key = malloc(sizeof(xkb_keysym_t)); | 61 | xkb_keysym_t *key = malloc(sizeof(xkb_keysym_t)); |
62 | if (!key) { | ||
63 | free_sway_binding(binding); | ||
64 | free_flat_list(split); | ||
65 | return cmd_results_new(CMD_FAILURE, "bindsym", | ||
66 | "Unable to allocate binding"); | ||
67 | } | ||
57 | *key = sym; | 68 | *key = sym; |
58 | list_add(binding->keys, key); | 69 | list_add(binding->keys, key); |
59 | } | 70 | } |
@@ -82,6 +93,10 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) { | |||
82 | } | 93 | } |
83 | 94 | ||
84 | struct sway_binding *binding = malloc(sizeof(struct sway_binding)); | 95 | struct sway_binding *binding = malloc(sizeof(struct sway_binding)); |
96 | if (!binding) { | ||
97 | return cmd_results_new(CMD_FAILURE, "bindsym", | ||
98 | "Unable to allocate binding"); | ||
99 | } | ||
85 | binding->keys = create_list(); | 100 | binding->keys = create_list(); |
86 | binding->modifiers = 0; | 101 | binding->modifiers = 0; |
87 | binding->release = false; | 102 | binding->release = false; |