]> git.ipfire.org Git - pakfire.git/commitdiff
buffer: Always allocate at least one chunk
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 Mar 2025 18:21:23 +0000 (18:21 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 Mar 2025 18:21:23 +0000 (18:21 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/buffer.c

index 55db5e8890ea0fb3282cf823e697dd85b93bb048..ae8fd11342d381c58d997d606797f6e5ed13e484 100644 (file)
@@ -41,6 +41,10 @@ void pakfire_buffer_free(struct pakfire_buffer* buffer) {
 
 // Rounds up length to the nearest chunk size
 static size_t pakfire_buffer_align(size_t length) {
+       // Always have at least one chunk
+       if (!length)
+               return CHUNK_SIZE;
+
        return ((length + CHUNK_SIZE - 1) / CHUNK_SIZE) * CHUNK_SIZE;
 }