From a555b53a612ebbb5aabee61269f090a2ac06b731 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Mon, 6 Nov 2023 18:35:09 -0500 Subject: [PATCH] update memory to check for size bounds: --- include/blt/std/memory.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/blt/std/memory.h b/include/blt/std/memory.h index 173c8fd..37a6365 100755 --- a/include/blt/std/memory.h +++ b/include/blt/std/memory.h @@ -11,6 +11,7 @@ #include #include #include "queue.h" +#include #include #include #include @@ -179,7 +180,11 @@ namespace blt explicit scoped_buffer(size_t size): _size(size) { - _buffer = new T[size]; + BLT_ASSERT(size >= 0); + if (size > 0) + _buffer = new T[size]; + else + _buffer = nullptr; } scoped_buffer(const scoped_buffer& copy)