SDL_memcpyMMX(): Fixed handling of overflow bytes.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 29 Oct 2011 01:11:47 -0400
changeset 6034 e228e94fef7f
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
--- a/src/video/SDL_blit_copy.c	Sat Oct 29 01:03:50 2011 -0400
+++ b/src/video/SDL_blit_copy.c	Sat Oct 29 01:11:47 2011 -0400
@@ -59,6 +59,7 @@
 static __inline__ void
 SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len)
 {
+    const int remain = (len & 63);
     int i;
 
     __m64* d64 = (__m64*)dst;
@@ -78,8 +79,11 @@
         s64 += 8;
     }
 
-    if (len & 63)
-        SDL_memcpy(dst, src, len & 63);
+    if (remain)
+    {
+        const int skip = len - remain;
+        SDL_memcpy(dst + skip, src + skip, remain);
+    }
 }
 #endif /* __MMX__ */