[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
This commit is contained in:
Dominic Chen 2022-03-16 13:40:58 -07:00
parent 7dda44c189
commit 9343fc7613

View File

@ -47,9 +47,12 @@ inline bool checkPosixMemalignAlignment(uptr Alignment) {
// costly division.
inline bool checkForCallocOverflow(uptr Size, uptr N, uptr *Product) {
#if __has_builtin(__builtin_umull_overflow) && (SCUDO_WORDSIZE == 64U)
return __builtin_umull_overflow(Size, N, Product);
return __builtin_umull_overflow(Size, N,
reinterpret_cast<unsigned long *>(Product));
#elif __has_builtin(__builtin_umul_overflow) && (SCUDO_WORDSIZE == 32U)
return __builtin_umul_overflow(Size, N, Product);
// On, e.g. armv7, uptr/uintptr_t may be defined as unsigned long
return __builtin_umul_overflow(Size, N,
reinterpret_cast<unsigned int *>(Product));
#else
*Product = Size * N;
if (!Size)