Mac: Fixed crash if SDL_GetDisplayDPI() got NULL pointers for output parameters.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Sun, 26 Jun 2016 21:08:57 +0200
changeset 10186 6c8e53149f0c
parent 10185 8eeab279c545
child 10187 1f0f8c95531d
Mac: Fixed crash if SDL_GetDisplayDPI() got NULL pointers for output parameters.
src/video/cocoa/SDL_cocoamodes.m
--- a/src/video/cocoa/SDL_cocoamodes.m	Sat Jun 25 19:40:44 2016 +0200
+++ b/src/video/cocoa/SDL_cocoamodes.m	Sun Jun 26 21:08:57 2016 +0200
@@ -323,9 +323,15 @@
     size_t pixelWidth = CGDisplayPixelsWide(data->display);
     size_t pixelHeight = CGDisplayPixelsHigh(data->display);
 
-    *ddpi = SDL_ComputeDiagonalDPI(pixelWidth, pixelHeight, displaySize.width / MM_IN_INCH, displaySize.height / MM_IN_INCH);
-    *hdpi = pixelWidth * MM_IN_INCH / displaySize.width;
-    *vdpi = pixelHeight * MM_IN_INCH / displaySize.height;
+    if (ddpi) {
+        *ddpi = SDL_ComputeDiagonalDPI(pixelWidth, pixelHeight, displaySize.width / MM_IN_INCH, displaySize.height / MM_IN_INCH);
+    }
+    if (hdpi) {
+        *hdpi = pixelWidth * MM_IN_INCH / displaySize.width;
+    }
+    if (vdpi) {
+        *vdpi = pixelHeight * MM_IN_INCH / displaySize.height;
+    }
 
     return 0;
 }