소스 검색

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
Sam Lantinga 2 년 전
부모
커밋
77bcd269be
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      src/video/SDL_surface.c

+ 2 - 2
src/video/SDL_surface.c

@@ -230,7 +230,7 @@ SDL_CreateRGBSurfaceFrom(void *pixels,
 
     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");
         return NULL;
     }
@@ -272,7 +272,7 @@ SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
 
     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");
         return NULL;
     }