From a672530595e0a5cc0558d9e51a09b35a62c87fe7 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 29 Oct 2011 01:11:47 -0400 Subject: [PATCH] SDL_memcpyMMX(): Fixed handling of overflow bytes. Thanks to Mason Wheeler for the fix! --- src/video/SDL_blit_copy.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/video/SDL_blit_copy.c b/src/video/SDL_blit_copy.c index c0cdd23a1..a9f98eb73 100644 --- a/src/video/SDL_blit_copy.c +++ b/src/video/SDL_blit_copy.c @@ -59,6 +59,7 @@ SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len) 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 @@ SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len) 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__ */