[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master e85bff0 3/3: Fix drain_reloc_list alignment bug
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master e85bff0 3/3: Fix drain_reloc_list alignment bug |
Date: |
Mon, 22 Apr 2019 00:16:32 -0400 (EDT) |
branch: master
commit e85bff0bbb60e1d819f8f5e00f8496026f27f7ea
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Fix drain_reloc_list alignment bug
* src/pdumper.c (dump_charset): Use alignof (struct charset),
not alignof (int), since struct charset might be more strictly
aligned than int. I think this is just a minor performance
issue, but we might as well use the correct alignment.
(drain_reloc_list): Use an alignment instead of a size for the
output alignment. This prevents undefined behavior when
alignof (struct emacs_reloc) == 8 and sizeof (dump_off) == 4
when building on x86-64 with gcc -fsanitize=undefined.
---
src/pdumper.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/pdumper.c b/src/pdumper.c
index 6ab8276..39931c6 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -3167,7 +3167,7 @@ dump_charset (struct dump_context *ctx, int cs_i)
#if CHECK_STRUCTS && !defined (HASH_charset_317C49E291)
# error "charset changed. See CHECK_STRUCTS comment."
#endif
- dump_align_output (ctx, alignof (int));
+ dump_align_output (ctx, alignof (struct charset));
const struct charset *cs = charset_table + cs_i;
struct charset out;
dump_object_start (ctx, &out, sizeof (out));
@@ -3816,7 +3816,8 @@ drain_reloc_list (struct dump_context *ctx,
Lisp_Object relocs = Fsort (Fnreverse (*reloc_list),
Qdump_emacs_portable__sort_predicate);
*reloc_list = Qnil;
- dump_align_output (ctx, sizeof (dump_off));
+ dump_align_output (ctx, max (alignof (struct dump_reloc),
+ alignof (struct emacs_reloc)));
struct dump_table_locator locator;
memset (&locator, 0, sizeof (locator));
locator.offset = ctx->offset;