Fix memory allocation in blockdata_retrieve()

This was functionally correct, but every call
malloced a new buffer and freed the previous one, rather
than only doing that when the buffer needed expansion.
This commit is contained in:
Simon Kelley
2026-01-24 22:00:35 +00:00
parent cb321709e9
commit 81f619612e

View File

@@ -202,11 +202,15 @@ void *blockdata_retrieve(struct blockdata *block, size_t len, void *data)
{
if (len > buff_len)
{
if (!(new = whine_malloc(len)))
blen = len + 1024;
if (!(new = whine_malloc(blen)))
return NULL;
if (buff)
free(buff);
buff = new;
buff_len = blen;
}
data = buff;
}