aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2023-03-20 17:36:43 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2023-03-21 11:16:03 +0400
commit74bc00c6b9065e34f04000a06c89cd04a814a599 (patch)
tree5dff4def2e3f275f31d6dfaa43ed1038c6f2f4f2
parente40283d9a13e9a26d58b089e243e46fe7724fe89 (diff)
downloadqemu-74bc00c6b9065e34f04000a06c89cd04a814a599.zip
qemu-74bc00c6b9065e34f04000a06c89cd04a814a599.tar.gz
qemu-74bc00c6b9065e34f04000a06c89cd04a814a599.tar.bz2
ui/dbus: fix passing SOCKET to GSocket API & leak
-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 <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20230320133643.1618437-4-marcandre.lureau@redhat.com>
-rw-r--r--ui/dbus.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ui/dbus.c b/ui/dbus.c
index 0513de9..b9e9698 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);