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

[libvirt] [PATCHv2 1/8] rpc: avoid memory leak on error



Detected by Coverity.  The leak is on an error path, but I'm not
sure whether that path is likely to be triggered in practice.

* src/rpc/virnetserverservice.c (virNetServerServiceAccept): Plug
leak.
---

v2: incorporate fixes suggested here:
https://www.redhat.com/archives/libvir-list/2011-July/msg00058.html

 src/rpc/virnetserverservice.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index e84f72c..8c250e2 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -82,7 +82,12 @@ cleanup:
     return;

 error:
-    virNetSocketFree(clientsock);
+    if (client) {
+        virNetServerClientClose(client);
+        virNetServerClientFree(client);
+    } else {
+        virNetSocketFree(clientsock);
+    }
 }


-- 
1.7.4.4


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