Skip to content

Commit

Permalink
Mac: Fixed crash if SDL_GetDisplayDPI() got NULL pointers for output …
Browse files Browse the repository at this point in the history
…parameters.
  • Loading branch information
philippwiesemann committed Jun 26, 2016
1 parent f4d33fc commit 2f016cf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/video/cocoa/SDL_cocoamodes.m
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2f016cf

Please sign in to comment.