Quellcode durchsuchen

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.
Paul Redmond vor 5 Jahren
Ursprung
Commit
a9779e12ea
1 geänderte Dateien mit 3 neuen und 0 gelöschten Zeilen
  1. 3 0
      AK/ByteBuffer.h

+ 3 - 0
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);