diff options
author | Alex Richardson <alexrichardson@google.com> | 2024-03-07 23:36:16 -0800 |
---|---|---|
committer | Alex Richardson <alexrichardson@google.com> | 2024-03-07 23:36:16 -0800 |
commit | 0bf259f52f5dc30c2c89ea3c85b23cc00cff0250 (patch) | |
tree | 27b73c1a80bfbbc093d8ae4ae1a07537758213fd | |
parent | bfa6444a332f82843f9fa44821d68fcc772e0272 (diff) |
[𝘀𝗽𝗿] initial versionupstream/users/arichardson/spr/sanitizer_allocatorcpp-ensure-at-least-sizeofvoid-alignment
Created using spr 1.3.6-beta.1
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp index 0513ae36fbc7..d7f8acd819ad 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp @@ -59,7 +59,7 @@ static void *RawInternalAlloc(uptr size, InternalAllocatorCache *cache, static void *RawInternalRealloc(void *ptr, uptr size, InternalAllocatorCache *cache) { - uptr alignment = 8; + constexpr usize alignment = Max<usize>(8, sizeof(void *)); if (cache == 0) { SpinMutexLock l(&internal_allocator_cache_mu); return internal_allocator()->Reallocate(&internal_allocator_cache, ptr, @@ -137,7 +137,8 @@ void InternalAllocatorUnlock() SANITIZER_NO_THREAD_SAFETY_ANALYSIS { } // LowLevelAllocator -constexpr uptr kLowLevelAllocatorDefaultAlignment = 8; +constexpr usize kLowLevelAllocatorDefaultAlignment = + Max<usize>(8, sizeof(void *)); constexpr uptr kMinNumPagesRounded = 16; constexpr uptr kMinRoundedSize = 65536; static uptr low_level_alloc_min_alignment = kLowLevelAllocatorDefaultAlignment; |