aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2016-12-15 18:17:36 -0500
committerDrew DeVault <sir@cmpwn.com>2016-12-15 19:01:41 -0500
commita2b914965686bb4352b8ebc4a46d898f5a793647 (patch)
treeb1dd50cfcb5b05b6119452ef2911a1221edf8f62
parent7784f1a905cad5ad805195dcc3cba23ff206501c (diff)
Add remaining sway allocation failure handling
-rw-r--r--sway/container.c2
-rw-r--r--sway/workspace.c10
2 files changed, 10 insertions, 2 deletions
diff --git a/sway/container.c b/sway/container.c
index e5284200..8a584efa 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -217,7 +217,7 @@ swayc_t *new_workspace(swayc_t *output, const char *name) {
workspace->y = output->y;
workspace->width = output->width;
workspace->height = output->height;
- workspace->name = strdup(name);
+ workspace->name = !name ? NULL : strdup(name);
workspace->visible = false;
workspace->floating = create_list();
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);
}