From d42ac98eece890e00d783ac761027324dc4159b2 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Sat, 30 Jan 2021 02:08:32 -0500 Subject: [PATCH] Use memmove instead of memcpy for overlapping copy (#47468) memcpy is defined to only work when the source and destination memory regions do not overlap. In here, they do. So let's use memmove instead. --- src/coreclr/ilasm/asmtemplates.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/ilasm/asmtemplates.h b/src/coreclr/ilasm/asmtemplates.h index 0393c71a4f2..37908967e2e 100644 --- a/src/coreclr/ilasm/asmtemplates.h +++ b/src/coreclr/ilasm/asmtemplates.h @@ -444,7 +444,7 @@ public: if (cmp == 0) { delete (*mid); - memcpy(mid,mid+1,(BYTE*)&m_Arr[m_ulOffset+m_ulCount]-(BYTE*)mid-1); + memmove(mid,mid+1,(BYTE*)&m_Arr[m_ulOffset+m_ulCount]-(BYTE*)mid-1); m_ulCount--; return TRUE; } -- GitLab