virnetdaemon: fix memory leak in virNetDaemonCallInhibit

g_variant_new() returns a weak reference which can be consumed by passing
to other g_variant* functions or to g_dbus_connection_call* functions.

This make it possible to call g_variant_new() directly as argument to
the functions above. Because this might be confusing I explicitly call
g_variant_ref_sink() to make it normal reference in both
virGDBusCallMethod() and virGDBusCallMethodWithFD() so the caller is
always responsible for the data.

Reported-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Pavel Hrdina 2020-09-23 16:31:21 +02:00
parent 784f204e7e
commit d202681781

View File

@ -469,7 +469,7 @@ virNetDaemonCallInhibit(virNetDaemonPtr dmn,
{
g_autoptr(GVariant) reply = NULL;
g_autoptr(GUnixFDList) replyFD = NULL;
GVariant *message = NULL;
g_autoptr(GVariant) message = NULL;
GDBusConnection *systemBus;
int fd;
int rc;