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>
This commit is contained in:
parent
e40283d9a1
commit
74bc00c6b9
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user