From 03a6de93aa2e11ae2e45d49f4489465854b8fcf0 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Thu, 15 Oct 2026 05:51:56 +0200 Subject: [PATCH] src/common/memory_allocator: preserve 64-bit alignment masks Use the value type for the alignment mask to prevent truncation of 64-bit values on 32-bit targets. --- src/common/memory_allocator.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/memory_allocator.h b/src/common/memory_allocator.h index 5760b0c75..2d7082351 100644 --- a/src/common/memory_allocator.h +++ b/src/common/memory_allocator.h @@ -76,7 +76,8 @@ class PageAllocator { template static T AlignUp(T offset, size_t alignment) { assert(alignment > 0 && ((alignment - 1) & alignment) == 0); - return (offset + (alignment - 1)) & ~(alignment - 1); + const T mask = static_cast(alignment - 1); + return (offset + mask) & ~mask; } // Allocates an array with requested amount of `bytes` and at a location with