Allow setting NULL palette on any surface

Fixes https://github.com/libsdl-org/SDL/issues/15654
This commit is contained in:
Sam Lantinga
2026-05-19 14:21:55 -07:00
parent f19dca3ca0
commit cfed9b3aca

View File

@@ -423,10 +423,14 @@ SDL_Palette *SDL_CreateSurfacePalette(SDL_Surface *surface)
bool SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
{
CHECK_PARAM(!SDL_SurfaceValid(surface) || !SDL_ISPIXELFORMAT_INDEXED(surface->format)) {
CHECK_PARAM(!SDL_SurfaceValid(surface)) {
return SDL_InvalidParamError("surface");
}
CHECK_PARAM(palette && !SDL_ISPIXELFORMAT_INDEXED(surface->format)) {
return SDL_SetError("Surface doesn't use a palette");
}
CHECK_PARAM(palette && palette->ncolors > (1 << SDL_BITSPERPIXEL(surface->format))) {
return SDL_SetError("Palette doesn't match surface format");
}