Check for null return from CGDisplayCopyAllDisplayModes()

This commit is contained in:
Cameron Gutman committed 2026-11-14 23:18:48 -06:00
1 parent 0d998a1247
commit 3da99d62e5
1 file changed
+6
+6
View File
@@ -277,6 +277,12 @@ bool StreamUtils::getNativeDesktopMode(int displayIndex, SDL_DisplayMode* mode,
// native on macOS using the SDL API alone. We'll talk to CoreGraphics to
// find the correct resolution and match it in our SDL list.
CFArrayRef modeList = CGDisplayCopyAllDisplayModes(displayIds[displayIndex], nullptr);
if (modeList == nullptr) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"CGDisplayCopyAllDisplayModes() returned NULL for display %d",
displayIndex);
return false;
}
CFIndex count = CFArrayGetCount(modeList);
for (CFIndex i = 0; i < count; i++) {
auto cgMode = (CGDisplayModeRef)(CFArrayGetValueAtIndex(modeList, i));