From: Pavel Hrdina Date: Wed, 23 Sep 2020 14:31:21 +0000 (+0200) Subject: virnetdaemon: fix memory leak in virNetDaemonCallInhibit X-Git-Tag: v6.8.0-rc1~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d20268178175cea7d86d19e370dc70e72905fc14;p=thirdparty%2Flibvirt.git 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 Signed-off-by: Pavel Hrdina Reviewed-by: Ján Tomko Reviewed-by: Peter Krempa --- diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index f3a5e9f75c..2e01244f74 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -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;