Skip to content

Commit 9343fc7

Browse files
committed
[scudo] Use cast on calls to __builtin_umul_overflow/__builtin_umull_overflow
Platforms may define uintptr_t differently, so perform an explicit cast Differential Revision: https://reviews.llvm.org/D121852
1 parent 7dda44c commit 9343fc7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler-rt/lib/scudo/standalone/wrappers_c_checks.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ inline bool checkPosixMemalignAlignment(uptr Alignment) {
4747
// costly division.
4848
inline bool checkForCallocOverflow(uptr Size, uptr N, uptr *Product) {
4949
#if __has_builtin(__builtin_umull_overflow) && (SCUDO_WORDSIZE == 64U)
50-
return __builtin_umull_overflow(Size, N, Product);
50+
return __builtin_umull_overflow(Size, N,
51+
reinterpret_cast<unsigned long *>(Product));
5152
#elif __has_builtin(__builtin_umul_overflow) && (SCUDO_WORDSIZE == 32U)
52-
return __builtin_umul_overflow(Size, N, Product);
53+
// On, e.g. armv7, uptr/uintptr_t may be defined as unsigned long
54+
return __builtin_umul_overflow(Size, N,
55+
reinterpret_cast<unsigned int *>(Product));
5356
#else
5457
*Product = Size * N;
5558
if (!Size)

0 commit comments

Comments
 (0)