From fce47c93252fe0be14e8c169f6bab8b0fd512cab Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Sat, 1 Aug 2020 21:01:24 +0200 Subject: [PATCH] Improve offset calculation in wide int builds MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * src/alloc.c (mark_maybe_object): Make sure that OFFSET isn’t widened during subtraction. --- src/alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index f203061161b..e556fc86a3b 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -4641,8 +4641,10 @@ mark_maybe_object (Lisp_Object obj) break; } - void *po = (char *) ((intptr_t) (char *) XLP (obj) - + (offset - LISP_WORD_TAG (type_tag))); + bool overflow + = INT_SUBTRACT_WRAPV (offset, LISP_WORD_TAG (type_tag), &offset); + eassert (!overflow); + void *po = (char *) ((intptr_t) (char *) XLP (obj) + offset); /* If the pointer is in the dump image and the dump has a record of the object starting at the place where the pointer points, we -- 2.39.2