From 66b16f1fc1cfb1ee68ccbbc09e56646e3ab1e6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 5 Apr 2017 17:53:00 +0200 Subject: [PATCH] X11: Add validation of RandR gamma ramp size --- README.md | 1 + src/x11_monitor.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 4c656285..155e5ae5 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: XDND support had multiple non-conformance issues (#968) - [X11] Bugfix: The RandR monitor path was disabled despite working RandR (#972) - [X11] Bugfix: IM-duplicated key events would leak at low polling rates (#747) +- [X11] Bugfix: Gamma ramp setting via RandR did not validate ramp size - [Linux] Bugfix: Event processing did not detect joystick disconnection (#932) - [Cocoa] Added support for Vulkan window surface creation via [MoltenVK](https://moltengl.com/moltenvk/) (#870) diff --git a/src/x11_monitor.c b/src/x11_monitor.c index f8d25e37..5c0516e6 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -453,6 +453,13 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken) { + if (XRRGetCrtcGammaSize(_glfw.x11.display, monitor->x11.crtc) != ramp->size) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "X11: Gamma ramp size must match current ramp size"); + return; + } + XRRCrtcGamma* gamma = XRRAllocGamma(ramp->size); memcpy(gamma->red, ramp->red, ramp->size * sizeof(unsigned short));