Rémi Bernon (@rbernon) commented about dlls/ntdll/unix/file.c:
static NTSTATUS cancel_io( HANDLE handle, IO_STATUS_BLOCK *io, IO_STATUS_BLOCK *io_status, BOOL only_thread ) { - unsigned int status; + unsigned int status, i, count = 8, size; + obj_handle_t *cancelled_handles = NULL; + data_size_t handles_size = 0; + HANDLE *handles; + + for (;;) + { + size = count * sizeof(*cancelled_handles); + cancelled_handles = malloc( size ); + if (!cancelled_handles) + return STATUS_NO_MEMORY; How about allocating and using only one array of HANDLE instead of having to handle allocation failures twice? sizeof(HANDLE) >= sizeof(obj_handle_t) so you can fill it with obj_handle_t and fix them up before waiting by moving them inline backwards.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/7797#note_102028