AK: Appending 0 bytes to a ByteBuffer should be a no-op (#1699)

- inserting an empty string into LibLine Editor triggered an assertion
  trying to grow a ByteBuffer by 0 bytes.
This commit is contained in:
Paul Redmond 2020-04-08 11:04:37 -04:00 committed by GitHub
parent 38dfd04633
commit a9779e12ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: sideshowbarker 2024-07-19 07:48:45 +09:00

View file

@ -211,6 +211,9 @@ public:
void append(const void* data, size_t data_size)
{
if (data_size == 0)
return;
ASSERT(data != nullptr);
int old_size = size();
grow(size() + data_size);
__builtin_memcpy(this->data() + old_size, data, data_size);