mirror of
https://github.com/libvirt/libvirt.git
synced 2026-08-04 18:33:18 -05:00
rpc: Fix memleak in virNetMessageEncodeHeader
My latest patch for RPC rework (a2c304f687) introduced a memory leak.
virNetMessageEncodeHeader() is calling VIR_ALLOC_N(msg->buffer, ...)
despite fact, that msg->buffer isn't VIR_FREE()'d on all paths calling
the function. Therefore, rather than injecting free statement switch to
VIR_REALLOC_N().
This commit is contained in:
@@ -219,7 +219,7 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg)
|
||||
unsigned int len = 0;
|
||||
|
||||
msg->bufferLength = VIR_NET_MESSAGE_MAX + VIR_NET_MESSAGE_LEN_MAX;
|
||||
if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0) {
|
||||
if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user