mirror of
https://git.suckless.org/dwm
synced 2024-12-27 03:16:32 +00:00
dwm crashes when opening 50+ clients (tile layout)
Many users new to dwm find themselves caught out by being kicked out to the login manager (dwm crashing) when they open 50+ clients for demonstration purposes. The number of clients reported varies depending on the resolution of the monitor. The cause of this is due to how the default tile layout calculates the height of the next client based on the position of the previous client. Because clients have a minimum size the (ty) position can exceed that of the window height, resulting in (m->wh - ty) becoming negative. The negative height stored as an unsigned int results in a very large height ultimately resulting in dwm crashing. This patch adds safeguards to prevent the ty and my positions from exceeding that of the window height.
This commit is contained in:
parent
ed3ab6b4fc
commit
f09418bbb6
1 changed files with 4 additions and 2 deletions
2
dwm.c
2
dwm.c
|
@ -1689,10 +1689,12 @@ tile(Monitor *m)
|
||||||
if (i < m->nmaster) {
|
if (i < m->nmaster) {
|
||||||
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||||
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
|
if (my + HEIGHT(c) < m->wh)
|
||||||
my += HEIGHT(c);
|
my += HEIGHT(c);
|
||||||
} else {
|
} else {
|
||||||
h = (m->wh - ty) / (n - i);
|
h = (m->wh - ty) / (n - i);
|
||||||
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
|
if (ty + HEIGHT(c) < m->wh)
|
||||||
ty += HEIGHT(c);
|
ty += HEIGHT(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue