summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-13 12:44:18 -0500
committerLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-13 14:41:36 -0500
commit3cdeb9bd5eafee18cb571baa711b8c1ffa9d3161 (patch)
tree797cc6919426548c6406e7199d59c03078142f44
parentAdded in command queue (diff)
downloadsway-3cdeb9bd5eafee18cb571baa711b8c1ffa9d3161.tar.gz
sway-3cdeb9bd5eafee18cb571baa711b8c1ffa9d3161.tar.zst
sway-3cdeb9bd5eafee18cb571baa711b8c1ffa9d3161.zip
Minor fix to memory management
-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) {
26 26
27 if (strcmp("workspace", args->items[0]) == 0 && args->length > 1) { 27 if (strcmp("workspace", args->items[0]) == 0 && args->length > 1) {
28 sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", args->items[1]); 28 sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", args->items[1]);
29 const char* target = args->items[1]; 29 char* target = malloc(strlen(args->items[1]) + 1);
30 30 strcpy(target, args->items[1]);
31 while (*target == ' ' || *target == '\t') 31 while (*target == ' ' || *target == '\t')
32 target++; 32 target++;
33 33
@@ -43,13 +43,14 @@ char *workspace_next_name(void) {
43 continue; 43 continue;
44 44
45 //Make sure that the workspace doesn't already exist 45 //Make sure that the workspace doesn't already exist
46 if (workspace_find_by_name(args->items[1])) 46 if (workspace_find_by_name(target)) {
47 continue; 47 continue;
48 }
48 49
49 list_free(args); 50 list_free(args);
50 51
51 sway_log(L_DEBUG, "Workspace: Found free name %s", args->items[1]); 52 sway_log(L_DEBUG, "Workspace: Found free name %s", target);
52 return args->items[1]; 53 return target;
53 } 54 }
54 } 55 }
55 // As a fall back, get the current number of active workspaces 56 // As a fall back, get the current number of active workspaces