Commit 2c079a2f6c7379c83fb9790e25487244a4ce7c11

Sylvain Becker 2020-11-27T09:42:14

SDL_FillRects: prevent empty SDL_surface from raising an error message It's legitimate to have a surface with 0 width or height (null 'pixels' pointer). But calling SDL_FillRects would wrongly set the error "You must lock the surface".

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c
index ecc5fe5..3deb501 100644
--- a/src/video/SDL_fillrect.c
+++ b/src/video/SDL_fillrect.c
@@ -314,6 +314,11 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
         return SDL_SetError("SDL_FillRect(): Unsupported surface format");
     }
 
+    /* Nothing to do */
+    if (dst->w == 0 || dst->h == 0) {
+        return 0;
+    }
+
     /* Perform software fill */
     if (!dst->pixels) {
         return SDL_SetError("SDL_FillRect(): You must lock the surface");