From 33524234142ac605517ccc70296b4a26689b896a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Mon, 20 Nov 2017 22:19:00 +0100 Subject: [PATCH] Fix decrementing the waiter count when destroying a WinAPI event with active waiters. --- source/eventcore/drivers/winapi/events.d | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/eventcore/drivers/winapi/events.d b/source/eventcore/drivers/winapi/events.d index 4500e29..23884e6 100644 --- a/source/eventcore/drivers/winapi/events.d +++ b/source/eventcore/drivers/winapi/events.d @@ -110,6 +110,10 @@ final class WinAPIEventDriverEvents : EventDriverEvents { auto pe = descriptor in m_events; assert(pe.refCount > 0); if (--pe.refCount == 0) { + // make sure to not leak any waiter references for pending waits + foreach (i; 0 .. pe.waiters.length) + m_core.removeWaiter(); + () @trusted nothrow { scope (failure) assert(false); destroy(pe.waiters);