Handle allocation failure in commands

This commit is contained in:
Drew DeVault 2016-12-15 17:39:09 -05:00
parent 8691ff1b63
commit 248df18c24
11 changed files with 78 additions and 16 deletions

View file

@ -26,6 +26,9 @@ struct cmd_results *bar_cmd_bindsym(int argc, char **argv) {
return cmd_results_new(CMD_INVALID, "bindsym", "Invalid mouse binding %s", argv[1]);
}
struct sway_mouse_binding *binding = malloc(sizeof(struct sway_mouse_binding));
if (!binding) {
return cmd_results_new(CMD_FAILURE, "bindsym", "Unable to allocate binding");
}
binding->button = numbutton;
binding->command = join_args(argv + 1, argc - 1);