From: Fredrik Bergroth Date: Tue, 23 Feb 2016 11:41:16 +0000 (+1100) Subject: Use memmove instead of memcpy on overlapping regions X-Git-Tag: emacs-25.1-rc1~18 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=916abe9;p=emacs.git Use memmove instead of memcpy on overlapping regions * src/editfns.c (Ftranspose_regions): Regions may overlap, so use memmove instead of memcpy (bug#19213). Copyright-paperwork-exempt: yes This is a backport from trunk. (cherry picked from commit 354f9f0fc6cc05ed98883447f9b2f37943d79160) --- diff --git a/src/editfns.c b/src/editfns.c index 360ec12ba98..412745d551d 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -4997,7 +4997,7 @@ Transposing beyond buffer boundaries is an error. */) start2_addr = BYTE_POS_ADDR (start2_byte); memcpy (temp, start1_addr, len1_byte); memcpy (start1_addr, start2_addr, len2_byte); - memcpy (start1_addr + len2_byte, start1_addr + len1_byte, len_mid); + memmove (start1_addr + len2_byte, start1_addr + len1_byte, len_mid); memcpy (start1_addr + len2_byte + len_mid, temp, len1_byte); SAFE_FREE ();