Mac: Fixed crash if SDL_GetDisplayDPI() got NULL pointers for output parameters.
authorPhilipp Wiesemann
Sun, 26 Jun 2016 21:08:57 +0200
changeset 101866c8e53149f0c
parent 10185 8eeab279c545
child 10187 1f0f8c95531d
Mac: Fixed crash if SDL_GetDisplayDPI() got NULL pointers for output parameters.
src/video/cocoa/SDL_cocoamodes.m
     1.1 --- a/src/video/cocoa/SDL_cocoamodes.m	Sat Jun 25 19:40:44 2016 +0200
     1.2 +++ b/src/video/cocoa/SDL_cocoamodes.m	Sun Jun 26 21:08:57 2016 +0200
     1.3 @@ -323,9 +323,15 @@
     1.4      size_t pixelWidth = CGDisplayPixelsWide(data->display);
     1.5      size_t pixelHeight = CGDisplayPixelsHigh(data->display);
     1.6  
     1.7 -    *ddpi = SDL_ComputeDiagonalDPI(pixelWidth, pixelHeight, displaySize.width / MM_IN_INCH, displaySize.height / MM_IN_INCH);
     1.8 -    *hdpi = pixelWidth * MM_IN_INCH / displaySize.width;
     1.9 -    *vdpi = pixelHeight * MM_IN_INCH / displaySize.height;
    1.10 +    if (ddpi) {
    1.11 +        *ddpi = SDL_ComputeDiagonalDPI(pixelWidth, pixelHeight, displaySize.width / MM_IN_INCH, displaySize.height / MM_IN_INCH);
    1.12 +    }
    1.13 +    if (hdpi) {
    1.14 +        *hdpi = pixelWidth * MM_IN_INCH / displaySize.width;
    1.15 +    }
    1.16 +    if (vdpi) {
    1.17 +        *vdpi = pixelHeight * MM_IN_INCH / displaySize.height;
    1.18 +    }
    1.19  
    1.20      return 0;
    1.21  }