Rémi Bernon (@rbernon) commented about dlls/ntdll/unix/sync.c:
{
if (!(ret = wine_server_call( req ))) handle = wine_server_ptr_handle( reply->handle );
}
SERVER_END_REQ;
if (!ret)
{
if (!server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))
{
if (InterlockedCompareExchange( &device, fd, -2 ) != -2)
{
/* someone beat us to it */
if (needs_close) close( fd );
NtClose( handle );
}
/* otherwise don't close the device */
This effectively leaks the handle? We have the fd cached, why do we care about the handle? What about something like that:
``` if (ret || server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL )) fd = -1; if (InterlockedCompareExchange( &device, fd, -2 ) != -2 && fd != -1 && needs_close) close( fd ); NtClose( handle ); ```