diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-12-17 13:23:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-17 13:23:44 -0500 |
commit | f04ee0e68d885d7e1101cc88f9a9337202041f1f (patch) | |
tree | fa4dc296a5f1377867752d320ceef4e4b0178bbf /sway/workspace.c | |
parent | 6c0fc2093641868df28c4087902a040f7fae05d4 (diff) | |
parent | d859f825d3612492678f5cd6cc6dc1f2647929e1 (diff) | |
download | sway-f04ee0e68d885d7e1101cc88f9a9337202041f1f.tar.xz |
Merge pull request #995 from SirCmpwn/memory-use
Handle allocation failures
Diffstat (limited to 'sway/workspace.c')
-rw-r--r-- | sway/workspace.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sway/workspace.c b/sway/workspace.c index 7b24d7d9..d804126b 100644 --- a/sway/workspace.c +++ b/sway/workspace.c @@ -121,6 +121,10 @@ char *workspace_next_name(const char *output_name) { l = 3; } char *name = malloc(l + 1); + if (!name) { + sway_log(L_ERROR, "Could not allocate workspace name"); + return NULL; + } sprintf(name, "%d", ws_num++); return name; } @@ -278,7 +282,11 @@ bool workspace_switch(swayc_t *workspace) { || (strcmp(prev_workspace_name, active_ws->name) && active_ws != workspace)) { free(prev_workspace_name); - prev_workspace_name = malloc(strlen(active_ws->name)+1); + prev_workspace_name = malloc(strlen(active_ws->name) + 1); + if (!prev_workspace_name) { + sway_log(L_ERROR, "Unable to allocate previous workspace name"); + return false; + } strcpy(prev_workspace_name, active_ws->name); } |