From 20586e37b22379c8991cdd4dc00e8bce5078c725 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 5 Jul 2019 13:56:57 +0000 Subject: [PATCH] Treat ReferenceCount as an atomic Signed-off-by: Jason A. Donenfeld --- wintun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wintun.c b/wintun.c index 8ec2090..698914b 100644 --- a/wintun.c +++ b/wintun.c @@ -1467,7 +1467,7 @@ TunWaitForReferencesToDropToZero(_In_ DEVICE_OBJECT *DeviceObject) MaxTries = TotalTime / SleepTime }; #pragma warning(suppress : 28175) - for (int Try = 0; Try < MaxTries && DeviceObject->ReferenceCount; ++Try) + for (INT Try = 0; Try < MaxTries && InterlockedGet(&DeviceObject->ReferenceCount); ++Try) NdisMSleep(SleepTime); }