[PATCH] libXinerama: Set number to 0 on error.

Tobias Stoeckmann tobias at stoeckmann.org
Sun Jan 22 14:18:04 UTC 2017


The documentation of XineramaQueryScreens states that number is always
set to the amount of screens in the returned array, but if the
communication with the X server fails, NULL is returned without
modifying number.

At least dwm relies on the fact that number is set to 0 on error, i.e.
when NULL is returned. As a NULL pointer contains 0 elements and the
documentation states that number contains the amount of elements of the
returned array, I think this should be fixed inside libXinerama.
---
 src/Xinerama.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Xinerama.c b/src/Xinerama.c
index 8472ec5..ee1f630 100644
--- a/src/Xinerama.c
+++ b/src/Xinerama.c
@@ -286,6 +286,7 @@ XineramaQueryScreens(
     if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
 	UnlockDisplay (dpy);
 	SyncHandle ();
+	*number = 0;
 	return NULL;
     }
 
-- 
2.11.0



More information about the xorg-devel mailing list