From 3a508602f51d1ea89e8e7e02599fccf8d6d3460f Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 15 Aug 2025 14:14:55 -0400 Subject: [PATCH] Make sure aligned_alloc args are valid --- src/arena_allocator.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/arena_allocator.hpp b/src/arena_allocator.hpp index 80f9dfb..82ae39d 100644 --- a/src/arena_allocator.hpp +++ b/src/arena_allocator.hpp @@ -93,7 +93,8 @@ private: * @throws std::bad_alloc if memory allocation fails */ static Block *create(size_t size, Block *prev) { - void *memory = std::aligned_alloc(alignof(Block), sizeof(Block) + size); + void *memory = std::aligned_alloc( + alignof(Block), align_up(sizeof(Block) + size, alignof(Block))); if (!memory) { throw std::bad_alloc(); }