[libunwind] [libunwind] Undefined behaviour pointer arithmetic with null pointer (PR #98648)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 19 07:08:45 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libunwind
Author: Daniel Kiss (DanielKristofKiss)
<details>
<summary>Changes</summary>
Fixes #<!-- -->91144
---
Full diff: https://github.com/llvm/llvm-project/pull/98648.diff
1 Files Affected:
- (modified) libunwind/src/UnwindCursor.hpp (+2-2)
``````````diff
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 2ec60e4c123d5..1fa95b4ebee19 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -230,8 +230,8 @@ void DwarfFDECache<A>::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 <typename A> class UnwindSectionHeader {
``````````
</details>
https://github.com/llvm/llvm-project/pull/98648
More information about the cfe-commits
mailing list