Don't create surfaces with invalid pixel formats
Fixes https://github.com/libsdl-org/SDL/issues/12556
This commit is contained in:
@@ -204,6 +204,11 @@ SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (format == SDL_PIXELFORMAT_UNKNOWN) {
|
||||
SDL_InvalidParamError("format");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!SDL_CalculateSurfaceSize(format, width, height, &size, &pitch, false /* not minimal pitch */)) {
|
||||
// Overflow...
|
||||
return NULL;
|
||||
@@ -250,6 +255,11 @@ SDL_Surface *SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (format == SDL_PIXELFORMAT_UNKNOWN) {
|
||||
SDL_InvalidParamError("format");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pitch == 0 && !pixels) {
|
||||
// The application will fill these in later with valid values
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user