diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2023-03-20 17:36:43 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2023-03-21 11:16:03 +0400 |
commit | 74bc00c6b9065e34f04000a06c89cd04a814a599 (patch) | |
tree | 5dff4def2e3f275f31d6dfaa43ed1038c6f2f4f2 | |
parent | e40283d9a13e9a26d58b089e243e46fe7724fe89 (diff) | |
download | qemu-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.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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); |