emacs-diffs
[Top][All Lists]
Advanced

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

emacs-28 de9d27f 1/2: Avoid undefined behaviour when copying part of str


From: Eli Zaretskii
Subject: emacs-28 de9d27f 1/2: Avoid undefined behaviour when copying part of structure
Date: Mon, 29 Nov 2021 15:31:03 -0500 (EST)

branch: emacs-28
commit de9d27f679d5e040c0ed4b974bc9225f6a330852
Author: Andreas Schwab <schwab@linux-m68k.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Avoid undefined behaviour when copying part of structure
    
    * src/dispnew.c (copy_row_except_pointers): Don't use address of
    subobject as starting point.
    
    (cherry picked from commit 6943786b5c1fe76ea05a3a810512bd6777883710)
---
 src/dispnew.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/dispnew.c b/src/dispnew.c
index 53eb898..4a9f2ba 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -1034,7 +1034,7 @@ copy_row_except_pointers (struct glyph_row *to, struct 
glyph_row *from)
 {
   enum { off = offsetof (struct glyph_row, x) };
 
-  memcpy (&to->x, &from->x, sizeof *to - off);
+  memcpy ((char *) to + off, (char *) from + off, sizeof *to - off);
 }
 
 



reply via email to

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