]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
client: fix memory leak in client msg
authorHao Wang <wanghao232@huawei.com>
Sat, 18 Jul 2020 07:43:30 +0000 (15:43 +0800)
committerJán Tomko <jtomko@redhat.com>
Wed, 9 Sep 2020 13:03:45 +0000 (15:03 +0200)
When closing client->waitDispatch in virNetClientIOEventLoopRemoveAll
or virNetClientIOEventLoopRemoveDone, VIR_FREE() is called to free
call->msg directly, resulting in leak of the memory call->msg->buffer
points to.
Use virNetMessageFree(call->msg) instead of VIR_FREE(call->msg).

Signed-off-by: Hao Wang <wanghao232@huawei.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/rpc/virnetclient.c

index b8f8bcece627ee26e8fcfb414867dde320ebd9c0..8d3e0176e0f136b9f9ee4af7c4b0d342564dccf0 100644 (file)
@@ -1523,7 +1523,7 @@ static bool virNetClientIOEventLoopRemoveDone(virNetClientCallPtr call,
         if (call->expectReply)
             VIR_WARN("Got a call expecting a reply but without a waiting thread");
         virCondDestroy(&call->cond);
-        VIR_FREE(call->msg);
+        virNetMessageFree(call->msg);
         VIR_FREE(call);
     }
 
@@ -1550,7 +1550,7 @@ virNetClientIOEventLoopRemoveAll(virNetClientCallPtr call,
 
     VIR_DEBUG("Removing call %p", call);
     virCondDestroy(&call->cond);
-    VIR_FREE(call->msg);
+    virNetMessageFree(call->msg);
     VIR_FREE(call);
     return true;
 }