mirror of
https://github.com/swaywm/sway.git
synced 2026-04-20 06:47:03 -04:00
Handle allocation failure in commands
This commit is contained in:
parent
8691ff1b63
commit
248df18c24
11 changed files with 78 additions and 16 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue