mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
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:
parent
38dfd04633
commit
a9779e12ea
1 changed files with 3 additions and 0 deletions
|
@ -211,6 +211,9 @@ public:
|
||||||
|
|
||||||
void append(const void* data, size_t data_size)
|
void append(const void* data, size_t data_size)
|
||||||
{
|
{
|
||||||
|
if (data_size == 0)
|
||||||
|
return;
|
||||||
|
ASSERT(data != nullptr);
|
||||||
int old_size = size();
|
int old_size = size();
|
||||||
grow(size() + data_size);
|
grow(size() + data_size);
|
||||||
__builtin_memcpy(this->data() + old_size, data, data_size);
|
__builtin_memcpy(this->data() + old_size, data, data_size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue