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

@ -47,6 +47,9 @@ struct cmd_results *cmd_set(int argc, char **argv) {
free(var->value);
} else {
var = malloc(sizeof(struct sway_variable));
if (!var) {
return cmd_results_new(CMD_FAILURE, "set", "Unable to allocate variable");
}
var->name = strdup(argv[0]);
list_add(config->symbols, var);
list_qsort(config->symbols, compare_set_qsort);