Fixed bug 3096 - SDL_BlitSurface with overlapping source and destination
authorSteffen Pankratz <kratz00@gmx.de>
Mon, 10 Oct 2016 18:28:05 +0200
changeset 10509f548233b2813
parent 10508 7235bc13912c
child 10510 01761b2d701e
Fixed bug 3096 - SDL_BlitSurface with overlapping source and destination
src/video/SDL_blit_copy.c
     1.1 --- a/src/video/SDL_blit_copy.c	Tue Oct 11 17:31:29 2016 +0200
     1.2 +++ b/src/video/SDL_blit_copy.c	Mon Oct 10 18:28:05 2016 +0200
     1.3 @@ -109,10 +109,20 @@
     1.4          overlap = (src < (dst + h*dstskip));
     1.5      }
     1.6      if (overlap) {
     1.7 -        while (h--) {
     1.8 -            SDL_memmove(dst, src, w);
     1.9 -            src += srcskip;
    1.10 -            dst += dstskip;
    1.11 +        if ( dst < src ) {
    1.12 +                while ( h-- ) {
    1.13 +                        SDL_memmove(dst, src, w);
    1.14 +                        src += srcskip;
    1.15 +                        dst += dstskip;
    1.16 +                }
    1.17 +        } else {
    1.18 +                src += ((h-1) * srcskip);
    1.19 +                dst += ((h-1) * dstskip);
    1.20 +                while ( h-- ) {
    1.21 +                        SDL_memmove(dst, src, w);
    1.22 +                        src -= srcskip;
    1.23 +                        dst -= dstskip;
    1.24 +                }
    1.25          }
    1.26          return;
    1.27      }