diff options
Diffstat (limited to 'libsanitizer/sanitizer_common/sanitizer_allocator_checks.h')
-rw-r--r-- | libsanitizer/sanitizer_common/sanitizer_allocator_checks.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libsanitizer/sanitizer_common/sanitizer_allocator_checks.h b/libsanitizer/sanitizer_common/sanitizer_allocator_checks.h index 978813222b5..9056ed57987 100644 --- a/libsanitizer/sanitizer_common/sanitizer_allocator_checks.h +++ b/libsanitizer/sanitizer_common/sanitizer_allocator_checks.h @@ -42,16 +42,18 @@ INLINE void *SetErrnoOnNull(void *ptr) { // of alignment. INLINE bool CheckAlignedAllocAlignmentAndSize(uptr alignment, uptr size) { #if SANITIZER_POSIX - return IsPowerOfTwo(alignment) && (size & (alignment - 1)) == 0; + return alignment != 0 && IsPowerOfTwo(alignment) && + (size & (alignment - 1)) == 0; #else - return size % alignment == 0; + return alignment != 0 && size % alignment == 0; #endif } // Checks posix_memalign() parameters, verifies that alignment is a power of two // and a multiple of sizeof(void *). INLINE bool CheckPosixMemalignAlignment(uptr alignment) { - return IsPowerOfTwo(alignment) && (alignment % sizeof(void *)) == 0; // NOLINT + return alignment != 0 && IsPowerOfTwo(alignment) && + (alignment % sizeof(void *)) == 0; // NOLINT } // Returns true if calloc(size, n) call overflows on size*n calculation. |