]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid undefined behaviour when copying part of structure
authorAndreas Schwab <schwab@linux-m68k.org>
Mon, 29 Nov 2021 09:29:40 +0000 (10:29 +0100)
committerEli Zaretskii <eliz@gnu.org>
Mon, 29 Nov 2021 12:45:40 +0000 (14:45 +0200)
* src/dispnew.c (copy_row_except_pointers): Don't use address of
subobject as starting point.

(cherry picked from commit 6943786b5c1fe76ea05a3a810512bd6777883710)

src/dispnew.c

index 53eb8984747c58da2376486f4c42432bba7b14e3..4a9f2bae44b9fe452dd6b3d363d5066348ba7474 100644 (file)
@@ -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);
 }