From: Michael Tremer Date: Sat, 22 Mar 2025 18:21:23 +0000 (+0000) Subject: buffer: Always allocate at least one chunk X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c69d17048681e693fed3df9772587dbd154246fe;p=pakfire.git buffer: Always allocate at least one chunk Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/buffer.c b/src/pakfire/buffer.c index 55db5e88..ae8fd113 100644 --- a/src/pakfire/buffer.c +++ b/src/pakfire/buffer.c @@ -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; }