[PATCH] rpc: Fix memleak in virNetMessageEncodeHeader

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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().
---
 src/rpc/virnetmessage.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
index dc4c212..82d5f8d 100644
--- a/src/rpc/virnetmessage.c
+++ b/src/rpc/virnetmessage.c
@@ -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;
     }
-- 
1.7.8.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]