[scudo] Use cast on calls to __builtin_umul_overflow/__builtin_umull_overflow
authorDominic Chen <ddchen@apple.com>
Wed, 16 Mar 2022 20:40:58 +0000 (13:40 -0700)
committerDominic Chen <ddchen@apple.com>
Mon, 28 Mar 2022 23:36:30 +0000 (16:36 -0700)
Platforms may define uintptr_t differently, so perform an explicit cast

Differential Revision: https://reviews.llvm.org/D121852

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

index ec9c1a1..815d400 100644 (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)