From 129e548169c56b9e9ed686e65e3509d4880d5502 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Wed, 1 Apr 2026 18:48:31 -0400
Subject: [PATCH] video: SDL_SetVideoMode should always reject bogus bpp
arguments.
Previously it would adjust it without failing if SDL_ANYFORMAT was set, but
that was a misunderstanding of what this flag does; it decides if its okay
to give you a shadow surface if you have an otherwise-reasonable bpp that the
hardware doesn't support.
Real SDL1.2 would fail with an error message with bpp=232 and flags=ANYFORMAT,
as made clear to us by the tests for a perl SDL1 binding, so while this change
makes sdl12-compat less forgiving, it makes it more _correct_ to what real 1.2
would do.
---
src/SDL12_compat.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 6627e1cd3..01fab23aa 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -6505,12 +6505,8 @@ SetVideoModeImpl(int width, int height, int bpp, Uint32 flags12)
}
if ((bpp != 8) && (bpp != 16) && (bpp != 24) && (bpp != 32)) {
- if (flags12 & SDL12_ANYFORMAT) {
- bpp = max_bpp;
- } else {
- SDL20_SetError("Unsupported bits-per-pixel");
- return NULL;
- }
+ SDL20_SetError("Invalid bits per pixel (range is {8...32})");
+ return NULL;
}
appfmt = BPPToPixelFormat(bpp);