1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

rpc: Fix memleak in virNetMessageEncodeHeader

My latest patch for RPC rework (a2c304f6872) 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:
Michal Privoznik 2012-06-11 14:21:00 +02:00
parent 0ec8262092
commit 539e9b34b9

View File

@ -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;
}