[PATCH] Fix memory leak dispatching domain events

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

When dispatching domain events we will create an XDR struct
containing the event info. Some of this data may be allocated
on the heap and so must be freed. The graphics event dispatcher
had a broken attempt to free one field, but missed others. All
the events have a dom->name string that needs freeing. The code
should have used the xdr_free() procedure for doing all this

* daemon/remote.c: Use xdr_free after dispatching events
---
 daemon/remote.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 0f088c6..34c6364 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -334,8 +334,6 @@ static int remoteRelayDomainEventGraphics(virConnectPtr conn ATTRIBUTE_UNUSED,
                                   REMOTE_PROC_DOMAIN_EVENT_GRAPHICS,
                                   (xdrproc_t)xdr_remote_domain_event_graphics_msg, &data);
 
-    VIR_FREE(data.subject.subject_val);
-
     return 0;
 }
 
@@ -2498,7 +2496,7 @@ remoteDispatchDomainEventSend(virNetServerClientPtr client,
     virNetMessagePtr msg;
 
     if (!(msg = virNetMessageNew()))
-        return;
+        goto cleanup;
 
     msg->header.prog = virNetServerProgramGetID(program);
     msg->header.vers = virNetServerProgramGetVersion(program);
@@ -2516,10 +2514,12 @@ remoteDispatchDomainEventSend(virNetServerClientPtr client,
     VIR_DEBUG("Queue event %d %zu", procnr, msg->bufferLength);
     virNetServerClientSendMessage(client, msg);
 
+    xdr_free(proc, data);
     return;
 
 cleanup:
     virNetMessageFree(msg);
+    xdr_free(proc, data);
 }
 
 static int
-- 
1.7.6

--
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]