Browse Source

haiku: fix modelist double-free

erysdren 2 months ago
parent
commit
8b47487547
1 changed files with 12 additions and 10 deletions
  1. 12 10
      src/video/haiku/SDL_bmodes.cc

+ 12 - 10
src/video/haiku/SDL_bmodes.cc

@@ -245,18 +245,20 @@ bool HAIKU_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
     uint32 count, i;
 
     // Get graphics-hardware supported modes
-    bscreen.GetModeList(&bmodes, &count);
-    bscreen.GetMode(&this_bmode);
-
-    for (i = 0; i < count; ++i) {
-        // FIXME: Apparently there are errors with colorspace changes
-        if (bmodes[i].space == this_bmode.space) {
-            _BDisplayModeToSdlDisplayMode(&bmodes[i], &mode);
-            SDL_AddFullscreenDisplayMode(display, &mode);
+    if (bscreen.GetModeList(&bmodes, &count) == B_OK && bscreen.GetMode(&this_bmode) == B_OK)
+    {
+        for (i = 0; i < count; ++i) {
+            // FIXME: Apparently there are errors with colorspace changes
+            if (bmodes[i].space == this_bmode.space) {
+                _BDisplayModeToSdlDisplayMode(&bmodes[i], &mode);
+                SDL_AddFullscreenDisplayMode(display, &mode);
+            }
         }
+        free(bmodes); // This should NOT be SDL_free()
+        return true;
     }
-    free(bmodes); // This should NOT be SDL_free()
-    return true;
+
+    return false;
 }