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 6943786b5c)
This commit is contained in:
Andreas Schwab 2021-11-29 10:29:40 +01:00 committed by Eli Zaretskii
parent c4daff9cf8
commit de9d27f679

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