update memory to check for size bounds:

v1
Brett 2023-11-06 18:35:09 -05:00
parent 1a72728aeb
commit a555b53a61
1 changed files with 6 additions and 1 deletions

View File

@ -11,6 +11,7 @@
#include <iterator> #include <iterator>
#include <cstring> #include <cstring>
#include "queue.h" #include "queue.h"
#include <blt/std/assert.h>
#include <cstdint> #include <cstdint>
#include <type_traits> #include <type_traits>
#include <algorithm> #include <algorithm>
@ -179,7 +180,11 @@ namespace blt
explicit scoped_buffer(size_t size): _size(size) 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) scoped_buffer(const scoped_buffer& copy)