From 7d43d10dd54ae2782f44b547ef24e47c18b3147c Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 11 Oct 2015 20:54:30 +1100 Subject: [PATCH] =?UTF-8?q?[Glide64]=20These=20buffers=20can=20overlap,=20?= =?UTF-8?q?so=20memmove()=20must=20be=20used=20instead=20of=20memcp?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/mupen64plus/mupen64plus-video-glide64mk2/commit/48e20bc79939ac518d982b95be25fa9c7326a754#diff-4a633600241920557d6c8b6d96dfb363R298 --- Source/Glide64/TexBuffer.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Source/Glide64/TexBuffer.cpp b/Source/Glide64/TexBuffer.cpp index d10741bed..92b2aef82 100644 --- a/Source/Glide64/TexBuffer.cpp +++ b/Source/Glide64/TexBuffer.cpp @@ -293,7 +293,7 @@ int OpenTextureBuffer(COLOR_IMAGE & cimage) grRenderBuffer( GR_BUFFER_BACKBUFFER ); rdp.texbufs[i].count--; if (j < rdp.texbufs[i].count) - memcpy(&(rdp.texbufs[i].images[j]), &(rdp.texbufs[i].images[j+1]), sizeof(TBUFF_COLOR_IMAGE)*(rdp.texbufs[i].count-j)); + memmove(&(rdp.texbufs[i].images[j]), &(rdp.texbufs[i].images[j+1]), sizeof(TBUFF_COLOR_IMAGE)*(rdp.texbufs[i].count-j)); } } } @@ -705,12 +705,7 @@ int FindTextureBuffer(wxUint32 addr, wxUint16 width) if (rdp.tbuff_tex->crc == 0) { rdp.tbuff_tex->crc = CalcCRC(rdp.tbuff_tex); - bCorrect = - (width == 1) - || (rdp.tbuff_tex->width == width) - || ( (rdp.tbuff_tex->width > 320) - && (rdp.tbuff_tex->width == (wxUint32)width*2) - ); + bCorrect = (width == 1) || (rdp.tbuff_tex->width == width) || ((rdp.tbuff_tex->width > 320) && (rdp.tbuff_tex->width == (wxUint32)width*2)); } else bCorrect = rdp.tbuff_tex->crc == CalcCRC(rdp.tbuff_tex); @@ -727,7 +722,7 @@ int FindTextureBuffer(wxUint32 addr, wxUint16 width) { rdp.texbufs[index].count--; if (j < rdp.texbufs[index].count) - memcpy(&(rdp.texbufs[index].images[j]), &(rdp.texbufs[index].images[j+1]), sizeof(TBUFF_COLOR_IMAGE)*(rdp.texbufs[index].count-j)); + memmove(&(rdp.texbufs[index].images[j]), &(rdp.texbufs[index].images[j+1]), sizeof(TBUFF_COLOR_IMAGE)*(rdp.texbufs[index].count-j)); } } }