BAN: memcpy only if we already have a buffer

This commit is contained in:
Bananymous
2023-01-13 00:15:40 +02:00
parent 75ee592fb5
commit c33c6c5785
3 changed files with 9 additions and 9 deletions

View File

@@ -214,7 +214,8 @@ namespace BAN
void* new_data = BAN::allocator(new_cap);
if (new_data == nullptr)
return Error::FromString("String: Could not allocate memory");
memcpy(new_data, m_data, m_size + 1);
if (m_data)
memcpy(new_data, m_data, m_size + 1);
BAN::deallocator(m_data);
m_data = (char*)new_data;
m_capasity = new_cap;