Make sure the surface used for a software renderer is a valid format

Fixes https://github.com/libsdl-org/SDL/issues/13323
This commit is contained in:
Sam Lantinga committed 2025-09-07 12:55:33 -07:00
1 parent 9ccdaa49f4
commit ab17d66884
1 file changed
+5
+5
View File
@@ -1125,6 +1125,11 @@ bool SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, S
return SDL_InvalidParamError("surface");
}
if (SDL_BITSPERPIXEL(surface->format) < 8 ||
SDL_BITSPERPIXEL(surface->format) > 32) {
return SDL_SetError("Unsupported surface format");
}
renderer->software = true;
data = (SW_RenderData *)SDL_calloc(1, sizeof(*data));