bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#19213: 25.0.50; [PATCH] * editfns.c (Ftranspose_regions): memmove in


From: Lars Ingebrigtsen
Subject: bug#19213: 25.0.50; [PATCH] * editfns.c (Ftranspose_regions): memmove instead of memcpy
Date: Tue, 23 Feb 2016 22:41:42 +1100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Fredrik Bergroth <address@hidden> writes:

> 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);

Thanks; applied to the Emacs trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]