glx: Reject glXSwapIntervalMESA greater than INT_MAX

It wouldn't work in any case, as the internal API only stores a signed
int, and GLX_EXT_swap_control_tear will overload the meaning of negative
values so we should avoid ambiguity.

If your application needs a swap interval in excess of ~414.25 days, I'm
very sorry.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6671>
This commit is contained in:
Adam Jackson 2020-09-09 15:54:21 -04:00
parent e648442ceb
commit b8239abdf8

View file

@ -51,7 +51,7 @@
#endif /* GLX_USE_WINDOWSGL */
#endif
#endif
#include <limits.h>
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
#include <xcb/glx.h>
@ -1796,6 +1796,9 @@ glXSwapIntervalMESA(unsigned int interval)
#ifdef GLX_DIRECT_RENDERING
struct glx_context *gc = __glXGetCurrentContext();
if (interval > INT_MAX)
return GLX_BAD_VALUE;
if (gc != &dummyContext && gc->isDirect) {
struct glx_screen *psc;