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

2017-01-24 Thread Adam Jackson
On Mon, 2017-01-23 at 19:00 +0100, Tobias Stoeckmann wrote: > On Mon, Jan 23, 2017 at 11:52:13AM -0500, Adam Jackson wrote: > > Not that any caller has likely made this mistake, but you want an > > if > > (number) before this, otherwise you turn a protocol error into a > > segfault. > > If a

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

2017-01-23 Thread Tobias Stoeckmann
On Mon, Jan 23, 2017 at 11:52:13AM -0500, Adam Jackson wrote: > Not that any caller has likely made this mistake, but you want an if > (number) before this, otherwise you turn a protocol error into a > segfault. If a caller supplies NULL, a segfault would always occur because the pointer is never

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

2017-01-23 Thread Adam Jackson
On Sun, 2017-01-22 at 15:18 +0100, Tobias Stoeckmann wrote: > @@ -286,6 +286,7 @@ XineramaQueryScreens( >  if (!_XReply (dpy, (xReply *) , 0, xFalse)) { >   UnlockDisplay (dpy); >   SyncHandle (); > + *number = 0; Not that any caller has likely made this mistake, but you want an

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

2017-01-22 Thread Tobias Stoeckmann
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