瀏覽代碼

Fixed crash when restoring the desktop mode on macOS

Fixes https://github.com/libsdl-org/SDL/issues/12460
Sam Lantinga 6 月之前
父節點
當前提交
80ae3a7516
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/video/cocoa/SDL_cocoamodes.m

+ 3 - 1
src/video/cocoa/SDL_cocoamodes.m

@@ -644,7 +644,9 @@ static CGError SetDisplayModeForDisplay(CGDirectDisplayID display, SDL_DisplayMo
         result = CGDisplaySetDisplayMode(display, moderef, NULL);
         if (result == kCGErrorSuccess) {
             // If this mode works, try it first next time.
-            CFArrayExchangeValuesAtIndices(data->modes, i, 0);
+            if (i > 0) {
+                CFArrayExchangeValuesAtIndices(data->modes, i, 0);
+            }
             break;
         }
     }