From 74bc00c6b9065e34f04000a06c89cd04a814a599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 20 Mar 2023 17:36:43 +0400 Subject: ui/dbus: fix passing SOCKET to GSocket API & leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -display dbus is not currently available to win32 users, so it's not considered a regression. Note also the close() leak fix in case of error. Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé Message-Id: <20230320133643.1618437-4-marcandre.lureau@redhat.com> --- ui/dbus.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'ui/dbus.c') diff --git a/ui/dbus.c b/ui/dbus.c index 0513de9918..b9e9698503 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -304,11 +304,20 @@ dbus_display_add_client(int csock, Error **errp) g_cancellable_cancel(dbus_display->add_client_cancellable); } +#ifdef WIN32 + socket = g_socket_new_from_fd(_get_osfhandle(csock), &err); +#else socket = g_socket_new_from_fd(csock, &err); +#endif if (!socket) { error_setg(errp, "Failed to setup D-Bus socket: %s", err->message); + close(csock); return false; } +#ifdef WIN32 + /* socket owns the SOCKET handle now, so release our osf handle */ + qemu_close_socket_osfhandle(csock); +#endif conn = g_socket_connection_factory_create_connection(socket); -- cgit v1.2.3