Commit 3dbc6a40ae8cfbed8f2d65310274a1dd1391d099

Sam Lantinga 2022-12-26T10:24:25

render: only enable clipping when the rectangle is valid Fixes https://github.com/libsdl-org/SDL/issues/6896 (cherry picked from commit 00f05dcf49602889733262fc810386592ff51736)

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 35357ec..399863d 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -2488,7 +2488,7 @@ int SDL_RenderSetClipRect(SDL_Renderer *renderer, const SDL_Rect *rect)
     int retval;
     CHECK_RENDERER_MAGIC(renderer, -1)
 
-    if (rect) {
+    if (rect && rect->w > 0 && rect->h > 0) {
         renderer->clipping_enabled = SDL_TRUE;
         renderer->clip_rect.x = (double)rect->x * renderer->scale.x;
         renderer->clip_rect.y = (double)rect->y * renderer->scale.y;