From a9779e12ea6bbe9015b668c5ee1ac0514da8a505 Mon Sep 17 00:00:00 2001 From: Paul Redmond Date: Wed, 8 Apr 2020 11:04:37 -0400 Subject: [PATCH] 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. --- AK/ByteBuffer.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index 3f8a245fdd7..af5f98823d1 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -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);