all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#19213: 25.0.50; [PATCH] * editfns.c (Ftranspose_regions): memmove instead of memcpy
@ 2014-11-28 20:26 Fredrik Bergroth
  2016-02-23 11:41 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Fredrik Bergroth @ 2014-11-28 20:26 UTC (permalink / raw)
  To: 19213

In one case, `memcpy' is used 4 times to transform [r1|mid|r2] into
[r2|mid|r1], but `dest' and `src' may overlap when copying the mid
interval, which is forbidden by `memcpy' and results in undefined
behavior. Instead use `memmove' like other cases do.
---
 src/editfns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/editfns.c b/src/editfns.c
index 0a07886..82bd26d 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -4898,7 +4898,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 ();

--
1.9.1





^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-23 11:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-28 20:26 bug#19213: 25.0.50; [PATCH] * editfns.c (Ftranspose_regions): memmove instead of memcpy Fredrik Bergroth
2016-02-23 11:41 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.