Fix two possible causes for range violations in the WinAPI handle map.

This commit is contained in:
Sönke Ludwig 2018-03-30 16:57:45 +02:00
parent 811ae63698
commit 242432c416
2 changed files with 4 additions and 1 deletions

View file

@ -170,8 +170,10 @@ final class WinAPIEventDriverCore : EventDriverCore {
auto ret = () @trusted { return MsgWaitForMultipleObjectsEx(cast(DWORD)m_registeredEvents.length, m_registeredEvents.ptr,
timeout_msecs, QS_ALLEVENTS, MWMO_ALERTABLE|MWMO_INPUTAVAILABLE); } ();
foreach (evt; m_ioEvents.consume)
while (!m_ioEvents.empty) {
auto evt = m_ioEvents.consumeOne();
evt.process(evt.error, evt.bytesTransferred, evt.overlapped);
}
if (ret == WAIT_IO_COMPLETION) got_event = true;
else if (ret >= WAIT_OBJECT_0 && ret < WAIT_OBJECT_0 + m_registeredEvents.length) {

View file

@ -204,6 +204,7 @@ final class WinAPIEventDriverFiles : EventDriverFiles {
{
FileFD id = cast(FileFD)cast(size_t)overlapped.hEvent;
auto handle = idToHandle(id);
if (handle == INVALID_HANDLE_VALUE) return;
static if (RO)
auto slot = () @trusted { return &overlapped.driver.m_handles[handle].file.write; } ();
else