mirror of
https://git.suckless.org/dmenu
synced 2026-10-01 05:22:30 +07:00
fix out-of-bounds read of the Xinerama screen array with no screens
This can happen if dmenu is run with Xinerama enabled and no screens are detected. Also fallback to the first screen if there is no intersection of the root pointer to the screens found. Reported by: jb19357 <jb19357@protonmail.com> Who used Claude to write a report. I cannot reproduce this issue, but it seems logical.
This commit is contained in:
@@ -639,6 +639,8 @@ setup(void)
|
||||
#ifdef XINERAMA
|
||||
i = 0;
|
||||
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||
if (n < 1)
|
||||
die("Xinerama reported no screens");
|
||||
XGetInputFocus(dpy, &w, &di);
|
||||
if (mon >= 0 && mon < n)
|
||||
i = mon;
|
||||
@@ -661,6 +663,9 @@ setup(void)
|
||||
for (i = 0; i < n; i++)
|
||||
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
|
||||
break;
|
||||
/* fallback to the first screen if there is no intersection */
|
||||
if (i >= n)
|
||||
i = 0;
|
||||
|
||||
x = info[i].x_org;
|
||||
y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||
|
||||
Reference in New Issue
Block a user