diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2017-12-29 11:28:10 +0100 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2018-01-05 00:07:34 +0100 |
commit | 28b8ea9f1ee57672f39e42521f6ed2aece0d3b2e (patch) | |
tree | fa6e5108bb016409c83aab990d39ae01d0b58123 | |
parent | apply_input_config: restore previous `current_input_config` (diff) | |
download | sway-28b8ea9f1ee57672f39e42521f6ed2aece0d3b2e.tar.gz sway-28b8ea9f1ee57672f39e42521f6ed2aece0d3b2e.tar.zst sway-28b8ea9f1ee57672f39e42521f6ed2aece0d3b2e.zip |
cmd_input: cleanup around current_input_config
- Restore old one if we weren't part of a block (should be NULL anyway)
- Check current_input_config got properly allocated
- free temporary current_input_config when done using it
-rw-r--r-- | sway/commands/input.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sway/commands/input.c b/sway/commands/input.c index ccb1d276..edf45e4c 100644 --- a/sway/commands/input.c +++ b/sway/commands/input.c | |||
@@ -24,7 +24,11 @@ struct cmd_results *cmd_input(int argc, char **argv) { | |||
24 | char **argv_new = argv+2; | 24 | char **argv_new = argv+2; |
25 | 25 | ||
26 | struct cmd_results *res; | 26 | struct cmd_results *res; |
27 | struct input_config *old_input_config = current_input_config; | ||
27 | current_input_config = new_input_config(argv[0]); | 28 | current_input_config = new_input_config(argv[0]); |
29 | if (!current_input_config) { | ||
30 | return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config"); | ||
31 | } | ||
28 | if (strcasecmp("accel_profile", argv[1]) == 0) { | 32 | if (strcasecmp("accel_profile", argv[1]) == 0) { |
29 | res = input_cmd_accel_profile(argc_new, argv_new); | 33 | res = input_cmd_accel_profile(argc_new, argv_new); |
30 | } else if (strcasecmp("click_method", argv[1]) == 0) { | 34 | } else if (strcasecmp("click_method", argv[1]) == 0) { |
@@ -60,6 +64,7 @@ struct cmd_results *cmd_input(int argc, char **argv) { | |||
60 | } else { | 64 | } else { |
61 | res = cmd_results_new(CMD_INVALID, "input <device>", "Unknown command %s", argv[1]); | 65 | res = cmd_results_new(CMD_INVALID, "input <device>", "Unknown command %s", argv[1]); |
62 | } | 66 | } |
63 | current_input_config = NULL; | 67 | free_input_config(current_input_config); |
68 | current_input_config = old_input_config; | ||
64 | return res; | 69 | return res; |
65 | } | 70 | } |