SDL_memcpyMMX(): Fixed handling of overflow bytes.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 29 Oct 2011 01:11:47 -0400
changeset 6034e228e94fef7f
parent 6033 8788e295d3c8
child 6035 9494ca1b6cf5
SDL_memcpyMMX(): Fixed handling of overflow bytes.

Thanks to Mason Wheeler for the fix!
src/video/SDL_blit_copy.c
     1.1 --- a/src/video/SDL_blit_copy.c	Sat Oct 29 01:03:50 2011 -0400
     1.2 +++ b/src/video/SDL_blit_copy.c	Sat Oct 29 01:11:47 2011 -0400
     1.3 @@ -59,6 +59,7 @@
     1.4  static __inline__ void
     1.5  SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len)
     1.6  {
     1.7 +    const int remain = (len & 63);
     1.8      int i;
     1.9  
    1.10      __m64* d64 = (__m64*)dst;
    1.11 @@ -78,8 +79,11 @@
    1.12          s64 += 8;
    1.13      }
    1.14  
    1.15 -    if (len & 63)
    1.16 -        SDL_memcpy(dst, src, len & 63);
    1.17 +    if (remain)
    1.18 +    {
    1.19 +        const int skip = len - remain;
    1.20 +        SDL_memcpy(dst + skip, src + skip, remain);
    1.21 +    }
    1.22  }
    1.23  #endif /* __MMX__ */
    1.24