[gtk/gtk-3-24] [Quartz]Check mode before setting the monitor scale factor.



commit 70b7b89411690b0c77b4f50fe9072e7160d345f2
Author: John Ralls <jralls ceridwen us>
Date:   Sat Jan 5 20:02:26 2019 -0800

    [Quartz]Check mode before setting the monitor scale factor.
    
    CGDisplayModeGetWidth returns 0 if mode is NULL; that happens if the
    CGDisplay is offline or mirroring another monitor and it leads to a
    divide-by-zero crash.
    
    Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1565

 gdk/quartz/gdkdisplay-quartz.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gdk/quartz/gdkdisplay-quartz.c b/gdk/quartz/gdkdisplay-quartz.c
index 165e92bf09..6d6ed0924e 100644
--- a/gdk/quartz/gdkdisplay-quartz.c
+++ b/gdk/quartz/gdkdisplay-quartz.c
@@ -253,14 +253,16 @@ configure_monitor (GdkMonitor *monitor)
   monitor->height_mm = height;
   monitor->geometry = disp_geometry;
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
-  if (gdk_quartz_osx_version () >= GDK_OSX_MOUNTAIN_LION)
+  if (mode && gdk_quartz_osx_version () >= GDK_OSX_MOUNTAIN_LION)
+  {
     monitor->scale_factor = CGDisplayModeGetPixelWidth (mode) / CGDisplayModeGetWidth (mode);
+    CGDisplayModeRelease (mode);
+  }
   else
 #endif
     monitor->scale_factor = 1;
   monitor->refresh_rate = refresh_rate;
   monitor->subpixel_layout = GDK_SUBPIXEL_LAYOUT_UNKNOWN;
-  CGDisplayModeRelease (mode);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]