mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-26 20:48:32 +00:00
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:
1 file changed
+5
-1
+5
-1
@@ -202,11 +202,15 @@ void *blockdata_retrieve(struct blockdata *block, size_t len, void *data)
|
|||||||
{
|
{
|
||||||
if (len > buff_len)
|
if (len > buff_len)
|
||||||
{
|
{
|
||||||
if (!(new = whine_malloc(len)))
|
blen = len + 1024;
|
||||||
|
if (!(new = whine_malloc(blen)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (buff)
|
if (buff)
|
||||||
free(buff);
|
free(buff);
|
||||||
|
|
||||||
buff = new;
|
buff = new;
|
||||||
|
buff_len = blen;
|
||||||
}
|
}
|
||||||
data = buff;
|
data = buff;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user