From: Andreas Schwab Date: Mon, 29 Nov 2021 09:29:40 +0000 (+0100) Subject: Avoid undefined behaviour when copying part of structure X-Git-Tag: emacs-28.0.90~27 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=de9d27f679d5e040c0ed4b974bc9225f6a330852;p=emacs.git 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) --- diff --git a/src/dispnew.c b/src/dispnew.c index 53eb8984747..4a9f2bae44b 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); }