From 710590e33d19649f08c716d827eb465e3a132d23 Mon Sep 17 00:00:00 2001 From: Daniel Kiss Date: Mon, 5 Aug 2024 11:16:51 +0200 Subject: [PATCH] [libunwind] Undefined behaviour pointer arithmetic with null pointer (#98648) Fixes #91144 --- libunwind/src/UnwindCursor.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 06e654197351..ce6dced535e7 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -230,8 +230,8 @@ void DwarfFDECache::iterateCacheEntries(void (*func)( } #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) - -#define arrayoffsetof(type, index, field) ((size_t)(&((type *)0)[index].field)) +#define arrayoffsetof(type, index, field) \ + (sizeof(type) * (index) + offsetof(type, field)) #if defined(_LIBUNWIND_SUPPORT_COMPACT_UNWIND) template class UnwindSectionHeader {