[libvirt PATCH 1/2] qemu: fix memory leak reported by coverity

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

 



Let g_autoptr clean up on early return.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 src/qemu/qemu_monitor_json.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index cba9ec7b19..2491cbf9b8 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4013,7 +4013,7 @@ int qemuMonitorJSONAddFileHandleToSet(qemuMonitorPtr mon,
                                       const char *opaque,
                                       qemuMonitorAddFdInfoPtr fdinfo)
 {
-    virJSONValuePtr args = NULL;
+    g_autoptr(virJSONValue) args = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     g_autoptr(virJSONValue) cmd = NULL;
 
@@ -4024,7 +4024,8 @@ int qemuMonitorJSONAddFileHandleToSet(qemuMonitorPtr mon,
         if (virJSONValueObjectAdd(args, "j:fdset-id", fdset, NULL) < 0)
             return -1;
 
-    if (!(cmd = qemuMonitorJSONMakeCommandInternal("add-fd", args)))
+    if (!(cmd = qemuMonitorJSONMakeCommandInternal("add-fd",
+                                                   g_steal_pointer(&args))))
         return -1;
 
     if (qemuMonitorJSONCommandWithFd(mon, cmd, fd, &reply) < 0)
-- 
2.26.2




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

  Powered by Linux