Free owindow when no con_id match or window
Patch status: merged
Patch by Tony Crisci
Long description:
This memory leak is related to matching on con_id or matching when the container has a null window. In that case, windows that do not match would leak the owindow struct.
To apply this patch, use:
curl http://cr.i3wm.org/patch/482/raw.patch | git am
b/src/commands.c
16 |
@@ -297,15 +297,16 @@ void cmd_criteria_match_windows(I3_CMD) { |
17 |
if (current_match->con_id == current->con) { |
18 |
DLOG("matches container!\n"); |
19 |
TAILQ_INSERT_TAIL(&owindows, current, owindows); |
20 |
+ } else { |
21 |
+ DLOG("doesnt match\n"); |
22 |
+ free(current); |
23 |
} |
24 |
} else if (current_match->mark != NULL && current->con->mark != NULL && |
25 |
regex_matches(current_match->mark, current->con->mark)) { |
26 |
DLOG("match by mark\n"); |
27 |
TAILQ_INSERT_TAIL(&owindows, current, owindows); |
28 |
} else { |
29 |
- if (current->con->window == NULL) |
30 |
- continue; |
31 |
- if (match_matches_window(current_match, current->con->window)) { |
32 |
+ if (current->con->window && match_matches_window(current_match, current->con->window)) { |
33 |
DLOG("matches window!\n"); |
34 |
TAILQ_INSERT_TAIL(&owindows, current, owindows); |
35 |
} else { |