diff options
author | 2015-08-19 11:27:48 +0200 | |
---|---|---|
committer | 2015-08-19 11:27:48 +0200 | |
commit | 95517ac77ebedb6e07011affd9520159acf38376 (patch) | |
tree | 3e83d55a4373e7d807b87a3a32befc8ded904adf /sway/workspace.c | |
parent | focus to only child (diff) | |
download | sway-95517ac77ebedb6e07011affd9520159acf38376.tar.gz sway-95517ac77ebedb6e07011affd9520159acf38376.tar.zst sway-95517ac77ebedb6e07011affd9520159acf38376.zip |
fix a few possible memory leaks
Diffstat (limited to 'sway/workspace.c')
-rw-r--r-- | sway/workspace.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sway/workspace.c b/sway/workspace.c index 60108752..180c8a66 100644 --- a/sway/workspace.c +++ b/sway/workspace.c | |||
@@ -31,7 +31,7 @@ char *workspace_next_name(void) { | |||
31 | char* target = malloc(strlen(args->items[1]) + 1); | 31 | char* target = malloc(strlen(args->items[1]) + 1); |
32 | strcpy(target, args->items[1]); | 32 | strcpy(target, args->items[1]); |
33 | while (*target == ' ' || *target == '\t') | 33 | while (*target == ' ' || *target == '\t') |
34 | target++; | 34 | target++; |
35 | 35 | ||
36 | // Make sure that the command references an actual workspace | 36 | // Make sure that the command references an actual workspace |
37 | // not a command about workspaces | 37 | // not a command about workspaces |
@@ -42,11 +42,15 @@ char *workspace_next_name(void) { | |||
42 | strcmp(target, "number") == 0 || | 42 | strcmp(target, "number") == 0 || |
43 | strcmp(target, "back_and_forth") == 0 || | 43 | strcmp(target, "back_and_forth") == 0 || |
44 | strcmp(target, "current") == 0) | 44 | strcmp(target, "current") == 0) |
45 | { | ||
46 | list_free(args); | ||
45 | continue; | 47 | continue; |
46 | 48 | } | |
47 | //Make sure that the workspace doesn't already exist | 49 | |
50 | //Make sure that the workspace doesn't already exist | ||
48 | if (workspace_find_by_name(target)) { | 51 | if (workspace_find_by_name(target)) { |
49 | continue; | 52 | list_free(args); |
53 | continue; | ||
50 | } | 54 | } |
51 | 55 | ||
52 | list_free(args); | 56 | list_free(args); |
@@ -54,6 +58,7 @@ char *workspace_next_name(void) { | |||
54 | sway_log(L_DEBUG, "Workspace: Found free name %s", target); | 58 | sway_log(L_DEBUG, "Workspace: Found free name %s", target); |
55 | return target; | 59 | return target; |
56 | } | 60 | } |
61 | list_free(args); | ||
57 | } | 62 | } |
58 | // As a fall back, get the current number of active workspaces | 63 | // As a fall back, get the current number of active workspaces |
59 | // and return that + 1 for the next workspace's name | 64 | // and return that + 1 for the next workspace's name |
@@ -77,7 +82,7 @@ swayc_t *workspace_create(const char* name) { | |||
77 | } | 82 | } |
78 | 83 | ||
79 | bool workspace_by_name(swayc_t *view, void *data) { | 84 | bool workspace_by_name(swayc_t *view, void *data) { |
80 | return (view->type == C_WORKSPACE) && | 85 | return (view->type == C_WORKSPACE) && |
81 | (strcasecmp(view->name, (char *) data) == 0); | 86 | (strcasecmp(view->name, (char *) data) == 0); |
82 | } | 87 | } |
83 | 88 | ||