sdl2-compat: SDL_RenderCopyEx(): Don't render a texture with an empty source rect

From 4ecba5c0a1acf60de832bf5a22f148809366eb1c Mon Sep 17 00:00:00 2001
From: Petar Popovic <[EMAIL REDACTED]>
Date: Fri, 25 Apr 2025 00:36:23 +0200
Subject: [PATCH] SDL_RenderCopyEx(): Don't render a texture with an empty
 source rect

---
 src/sdl2_compat.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 12453ea..b12c283 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -6331,6 +6331,10 @@ SDL_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture,
         srcfrect.w = (float)srcrect->w;
         srcfrect.h = (float)srcrect->h;
         psrcfrect = &srcfrect;
+
+        if (srcrect->w == 0 || srcrect->h == 0) {
+            return 0;
+        }
     }
 
     if (dstrect) {
@@ -6366,6 +6370,10 @@ SDL_RenderCopyExF(SDL_Renderer *renderer, SDL_Texture *texture,
         srcfrect.w = (float)srcrect->w;
         srcfrect.h = (float)srcrect->h;
         psrcfrect = &srcfrect;
+
+        if (srcrect->w == 0 || srcrect->h == 0) {
+            return 0;
+        }
     }
 
     retval = SDL3_RenderTextureRotated(renderer, texture, psrcfrect, dstrect, angle, center, flip) ? 0 : -1;