]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: fix memory leak reported by coverity
authorJonathon Jongsma <jjongsma@redhat.com>
Fri, 23 Oct 2020 21:40:08 +0000 (16:40 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 23 Oct 2020 22:39:25 +0000 (18:39 -0400)
Let g_autoptr clean up on early return.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/qemu/qemu_monitor_json.c

index cba9ec7b19c0ea2630eb93041aaceb5379ba3d52..604fcda1e3b3f3a3330511b2089f8d12bb908dcd 100644 (file)
@@ -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,7 @@ 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)