浏览代码

X11: Add validation of RandR gamma ramp size

Camilla Löwy 8 年之前
父节点
当前提交
66b16f1fc1
共有 2 个文件被更改,包括 8 次插入0 次删除
  1. 1 0
      README.md
  2. 7 0
      src/x11_monitor.c

+ 1 - 0
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)

+ 7 - 0
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));