add null check

v1
Brett 2024-06-26 18:55:11 -04:00
parent 2a34be2e7b
commit cdb91d8007
3 changed files with 15 additions and 12 deletions

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake) include(cmake/color.cmake)
set(BLT_VERSION 0.17.19) set(BLT_VERSION 0.17.20)
set(BLT_TEST_VERSION 0.0.1) set(BLT_TEST_VERSION 0.0.1)
set(BLT_TARGET BLT) set(BLT_TARGET BLT)

View File

@ -468,6 +468,8 @@ namespace blt
size = std::max(size_, size); size = std::max(size_, size);
size = blt::mem::next_byte_allocation(size); size = blt::mem::next_byte_allocation(size);
T* new_buffer = new T[size]; T* new_buffer = new T[size];
if (buffer_ != nullptr)
{
if constexpr (std::is_trivially_copyable_v<T>) if constexpr (std::is_trivially_copyable_v<T>)
{ {
std::memcpy(new_buffer, buffer_, size_ * sizeof(T)); std::memcpy(new_buffer, buffer_, size_ * sizeof(T));
@ -482,6 +484,7 @@ namespace blt
new_buffer[i] = std::move(buffer_[i]); new_buffer[i] = std::move(buffer_[i]);
} }
delete[] buffer_; delete[] buffer_;
}
buffer_ = new_buffer; buffer_ = new_buffer;
size_ = size; size_ = size;
} }

@ -1 +1 @@
Subproject commit d88c5e15079047777b418132ece5879e7c9aaa2b Subproject commit 10368163ab1f4367d2f0685b5928b1c973ebd1ec