Commit 5ae90ef67a957307e857d9e819be72326d5aa464

Sam Lantinga 2017-09-21T01:22:40

Fixed bug 3788 - software renderer crashes in SDL_RenderCopyEx with rotation and dstrect w or h is 0 Anthony This is what's making the software renderer crash with rotated destination rectangles of w or h = 0: SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2");

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c
index 6b6c2fa..4476204 100644
--- a/src/render/software/SDL_rotate.c
+++ b/src/render/software/SDL_rotate.c
@@ -257,7 +257,7 @@ _transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int 
                 dy = (sdy >> 16);
                 if (flipx) dx = sw - dx;
                 if (flipy) dy = sh - dy;
-                if ((unsigned)dx < (unsigned)sw && (unsigned)dy < (unsigned)sh) {
+                if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) {
                     sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy) + dx;
                     c00 = *sp;
                     sp += 1;