aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/assign.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2016-12-17 13:23:44 -0500
committerGitHub <noreply@github.com>2016-12-17 13:23:44 -0500
commitf04ee0e68d885d7e1101cc88f9a9337202041f1f (patch)
treefa4dc296a5f1377867752d320ceef4e4b0178bbf /sway/commands/assign.c
parent6c0fc2093641868df28c4087902a040f7fae05d4 (diff)
parentd859f825d3612492678f5cd6cc6dc1f2647929e1 (diff)
downloadsway-f04ee0e68d885d7e1101cc88f9a9337202041f1f.tar.xz
Merge pull request #995 from SirCmpwn/memory-use
Handle allocation failures
Diffstat (limited to 'sway/commands/assign.c')
-rw-r--r--sway/commands/assign.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sway/commands/assign.c b/sway/commands/assign.c
index 53c599ca..992b4692 100644
--- a/sway/commands/assign.c
+++ b/sway/commands/assign.c
@@ -23,10 +23,16 @@ struct cmd_results *cmd_assign(int argc, char **argv) {
char *movecmd = "move container to workspace ";
int arglen = strlen(movecmd) + strlen(*argv) + 1;
char *cmdlist = calloc(1, arglen);
-
+ if (!cmdlist) {
+ return cmd_results_new(CMD_FAILURE, "assign", "Unable to allocate command list");
+ }
snprintf(cmdlist, arglen, "%s%s", movecmd, *argv);
struct criteria *crit = malloc(sizeof(struct criteria));
+ if (!crit) {
+ free(cmdlist);
+ return cmd_results_new(CMD_FAILURE, "assign", "Unable to allocate criteria");
+ }
crit->crit_raw = strdup(criteria);
crit->cmdlist = cmdlist;
crit->tokens = create_list();