From 1dc08ca723dacc0ec685f0ba139a79629691544a Mon Sep 17 00:00:00 2001 From: Brett Date: Sat, 9 Mar 2024 12:57:58 -0500 Subject: [PATCH] add null check --- CMakeLists.txt | 2 +- include/blt/std/allocator.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1c6de4..66ae3ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5) include(cmake/color.cmake) -set(BLT_VERSION 0.14.8) +set(BLT_VERSION 0.14.9) set(BLT_TEST_VERSION 0.0.1) set(BLT_TARGET BLT) diff --git a/include/blt/std/allocator.h b/include/blt/std/allocator.h index 907fd2b..ede749e 100644 --- a/include/blt/std/allocator.h +++ b/include/blt/std/allocator.h @@ -728,6 +728,8 @@ namespace blt */ void* allocate_bytes(blt::size_t bytes, blt::size_t alignment) { + if (head == nullptr) + return nullptr; blt::size_t remaining_bytes = BLOCK_REMAINDER - static_cast(head->metadata.offset - head->buffer); auto pointer = static_cast(head->metadata.offset); return std::align(alignment, bytes, pointer, remaining_bytes);