surface: cannot set a palette to a non-indexed surface
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled

This fixes a UBSAN warning later in this function where it calculates
(1 << SDL_BITSPERPIXEL(surface->format)). The bpp might be >= 32 and
out of range for a bit shift.
This commit is contained in:
Anonymous Maarten
2026-05-15 03:47:28 +02:00
committed by Sam Lantinga
parent 6b26332785
commit d5af35e3fb
+1 -1
View File
@@ -423,7 +423,7 @@ SDL_Palette *SDL_CreateSurfacePalette(SDL_Surface *surface)
bool SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
{
CHECK_PARAM(!SDL_SurfaceValid(surface)) {
CHECK_PARAM(!SDL_SurfaceValid(surface) || !SDL_ISPIXELFORMAT_INDEXED(surface->format)) {
return SDL_InvalidParamError("surface");
}