Commit 6db47e98a03b62cf2d5216b62c0a1aeda7622be6
Fix crash on forgetting a window on a stack
Similarly to b2a72cf798357b55d11140a4d5153842381f549e which was caused
by `c->next` following `free(c)`, `s->next` is following `free(s)`
causing a crash.
A way to reproduce:
1. Start xterm
2. Run `gvim -f`
3. Put GVim's window on a stack
4. Press Ctrl-Z in xterm
5. Execute `exit` twice (first time just prints a warning about a
stopped job)
6. euclid-wm should crash here on trying to forget a window that's
currently hidden, specifically on dropping a corresponding
`struct stack_item`
Author: xaizek
Author date (UTC): 2023-12-25 17:53
Committer name: xaizek
Committer date (UTC): 2023-12-25 18:01
Parent(s): b4e6301cacaece0263501a564104e851412bb89e
Signing key: 99DC5E4DB05F6BE2
Tree: 9073178ef3632b89dbf731ba914d2fdf0ab14757
File euclid-wm.c changed (mode: 100644) (index 7799b61..fe0e801) |
... |
... |
void forget_win (Window id) { |
1026 |
1026 |
while (v != NULL) { |
while (v != NULL) { |
1027 |
1027 |
s = v->stack; |
s = v->stack; |
1028 |
1028 |
while (s != NULL) { |
while (s != NULL) { |
|
1029 |
|
//storing this in case the entry will get free()'d |
|
1030 |
|
struct stack_item *next_s = s->next; |
|
1031 |
|
|
1029 |
1032 |
if (s->win == w) { |
if (s->win == w) { |
1030 |
1033 |
if (s == v->stack) { |
if (s == v->stack) { |
1031 |
1034 |
v->stack = s->next; |
v->stack = s->next; |
|
... |
... |
void forget_win (Window id) { |
1048 |
1051 |
}; |
}; |
1049 |
1052 |
free(s); |
free(s); |
1050 |
1053 |
}; |
}; |
1051 |
|
s = s->next; |
|
|
1054 |
|
|
|
1055 |
|
s = next_s; |
1052 |
1056 |
}; |
}; |
1053 |
1057 |
v = v->next; |
v = v->next; |
1054 |
1058 |
}; |
}; |