]> 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)
committerAndreas Schwab <schwab@linux-m68k.org>
Mon, 29 Nov 2021 09:30:10 +0000 (10:30 +0100)
* src/dispnew.c (copy_row_except_pointers): Don't use address of
subobject as starting point.

src/dispnew.c

index f3f110a8f27b8e98f42329c6936b05f1a41601ab..a976bf94c5ef8ca1ab1972195ccb0e889e59b1d9 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);
 }