aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorLuminarys <kizunanohikari@gmail.com>2015-08-13 12:44:18 -0500
committerLuminarys <kizunanohikari@gmail.com>2015-08-13 14:41:36 -0500
commit3cdeb9bd5eafee18cb571baa711b8c1ffa9d3161 (patch)
tree797cc6919426548c6406e7199d59c03078142f44 /sway
parentab130fb56b5c450d3821cfdfc18fc7a37487c70a (diff)
Minor fix to memory management
Diffstat (limited to 'sway')
-rw-r--r--sway/workspace.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sway/workspace.c b/sway/workspace.c
index 7b23b7d1..906d0c5d 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -26,8 +26,8 @@ char *workspace_next_name(void) {
if (strcmp("workspace", args->items[0]) == 0 && args->length > 1) {
sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", args->items[1]);
- const char* target = args->items[1];
-
+ char* target = malloc(strlen(args->items[1]) + 1);
+ strcpy(target, args->items[1]);
while (*target == ' ' || *target == '\t')
target++;
@@ -43,13 +43,14 @@ char *workspace_next_name(void) {
continue;
//Make sure that the workspace doesn't already exist
- if (workspace_find_by_name(args->items[1]))
+ if (workspace_find_by_name(target)) {
continue;
+ }
list_free(args);
- sway_log(L_DEBUG, "Workspace: Found free name %s", args->items[1]);
- return args->items[1];
+ sway_log(L_DEBUG, "Workspace: Found free name %s", target);
+ return target;
}
}
// As a fall back, get the current number of active workspaces