From fae4b9cc5a61b3f3dfdb67aae5daa000bd0da705 Mon Sep 17 00:00:00 2001 From: henrypp Date: Tue, 27 Apr 2021 19:00:06 +0600 Subject: [PATCH] fix interlocked operations --- src/log.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/log.c b/src/log.c index 0a91e67c..83094196 100644 --- a/src/log.c +++ b/src/log.c @@ -354,7 +354,7 @@ VOID _wfp_logsubscribe (_In_ HANDLE hengine) HANDLE hevent; ULONG code; - current_handle = InterlockedCompareExchangePointer (&config.hnetevent, NULL, config.hnetevent); + current_handle = InterlockedCompareExchangePointer (&config.hnetevent, NULL, NULL); if (current_handle) return; // already subscribed @@ -422,14 +422,17 @@ CleanupExit: VOID _wfp_logunsubscribe (_In_ HANDLE hengine) { - HANDLE current_handle = InterlockedCompareExchangePointer (&config.hnetevent, NULL, config.hnetevent); + HANDLE current_handle; + ULONG code; + + current_handle = InterlockedCompareExchangePointer (&config.hnetevent, NULL, config.hnetevent); if (!current_handle) return; _app_loginit (FALSE); // destroy log file handle if present - ULONG code = FwpmNetEventUnsubscribe (hengine, current_handle); + code = FwpmNetEventUnsubscribe (hengine, current_handle); if (code != ERROR_SUCCESS) _r_log (LOG_LEVEL_WARNING, 0, L"FwpmNetEventUnsubscribe", code, NULL);