From 8b474875478f956a77934a0dca2299fdec44e55c Mon Sep 17 00:00:00 2001
From: erysdren <[EMAIL REDACTED]>
Date: Wed, 7 Jan 2026 00:49:56 -0600
Subject: [PATCH] haiku: fix modelist double-free
---
src/video/haiku/SDL_bmodes.cc | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/video/haiku/SDL_bmodes.cc b/src/video/haiku/SDL_bmodes.cc
index e099587713f52..0f31191ffd3d2 100644
--- a/src/video/haiku/SDL_bmodes.cc
+++ b/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;
}