]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
buffer: Support length == 0 for ply_buffer_append_bytes
authorRay Strode <rstrode@redhat.com>
Sat, 26 Nov 2022 16:15:59 +0000 (11:15 -0500)
committerRay Strode <rstrode@redhat.com>
Tue, 29 Nov 2022 14:22:06 +0000 (09:22 -0500)
Right now callers of ply_buffer_append_bytes have to be
very careful to make sure the data they're appending is
non-zero in length. This is kind of inconvenient, since
it's not unusual for data to come in that's zero bytes
long.

For simplicity, this commit just makes
ply_buffer_append_bytes support that use case.

src/libply/ply-buffer.c

index 7392ee6b048ef30257e3cde6aea036bfdd53ec0f..e91eb0d6b357007f9f83703483714e91370c1a72 100644 (file)
@@ -181,10 +181,12 @@ ply_buffer_append_bytes (ply_buffer_t *buffer,
 {
         assert (buffer != NULL);
         assert (bytes_in != NULL);
-        assert (length != 0);
 
         const uint8_t *bytes = bytes_in;
 
+        if (length == 0)
+                return;
+
         if (length > PLY_BUFFER_MAX_BUFFER_CAPACITY) {
                 bytes += length - (PLY_BUFFER_MAX_BUFFER_CAPACITY - 1);
                 length = (PLY_BUFFER_MAX_BUFFER_CAPACITY - 1);
@@ -257,4 +259,3 @@ ply_buffer_clear (ply_buffer_t *buffer)
         memset (buffer->data, '\0', buffer->capacity);
         buffer->size = 0;
 }
-