Allow creating an empty surface with pitch 0

This fixes Maelstrom, which creates an empty staging surface and then uses it for transfer to texture
This commit is contained in:
Sam Lantinga 2022-11-16 22:23:16 -08:00
parent a1702d463c
commit 77bcd269be
1 changed files with 2 additions and 2 deletions

View File

@ -230,7 +230,7 @@ SDL_CreateRGBSurfaceFrom(void *pixels,
minimalPitch = SDL_CalculatePitch(format, width, SDL_TRUE); minimalPitch = SDL_CalculatePitch(format, width, SDL_TRUE);
if (pitch < 0 || ((size_t) pitch) < minimalPitch) { if (pitch < 0 || (pitch > 0 && ((size_t) pitch) < minimalPitch)) {
SDL_InvalidParamError("pitch"); SDL_InvalidParamError("pitch");
return NULL; return NULL;
} }
@ -272,7 +272,7 @@ SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
minimalPitch = SDL_CalculatePitch(format, width, SDL_TRUE); minimalPitch = SDL_CalculatePitch(format, width, SDL_TRUE);
if (pitch < 0 || ((size_t) pitch) < minimalPitch) { if (pitch < 0 || (pitch > 0 && ((size_t) pitch) < minimalPitch)) {
SDL_InvalidParamError("pitch"); SDL_InvalidParamError("pitch");
return NULL; return NULL;
} }