Rémi Bernon (@rbernon) commented about dlls/ntdll/unix/file.c:
SERVER_END_REQ;
if (status != STATUS_BUFFER_OVERFLOW)
break;
}
if (!status)
{
handles = (HANDLE *)cancelled_handles;
for (i = count - 1; i >= 0; i--)
handles[i] = wine_server_ptr_handle( cancelled_handles[i] );
NtWaitForMultipleObjects( count, handles, FALSE, TRUE, NULL );
free( cancelled_handles );
}
return status;
}
But I would also rather do it like this, to reduce the scope of the pointer aliasing, and with some additional fixups:
```suggestion:-45+0 { unsigned int status, count = 8; HANDLE *handles; int i;
do { if (!(handles = malloc( count * sizeof(*handles) ))) return STATUS_NO_MEMORY;
SERVER_START_REQ( cancel_async ) { object_handle_t *server_handles = (object_handle_t *)handles;
req->handle = wine_server_obj_handle( handle ); req->iosb = wine_server_client_ptr( io ); req->only_thread = only_thread; wine_server_set_reply( req, server_handles, count * sizeof(*server_handles) ); if (!(status = wine_server_call( req ))) { for (i = count - 1; i >= 0; i--) handles[i] = wine_server_ptr_handle( server_handles[i] ); io_status->Status = status; io_status->Information = 0; } else if (status == STATUS_BUFFER_OVERFLOW) { count = reply->handles_size / sizeof(*server_handles); free( handles ); } } SERVER_END_REQ; } while (status == STATUS_BUFFER_OVERFLOW);
if (!status) NtWaitForMultipleObjects( count, handles, FALSE, TRUE, NULL ); free( handles ); return status; } ```