From 39dc64f0f819054507267f89bac61fa310d1fd4d Mon Sep 17 00:00:00 2001 From: jpark37 Date: Thu, 27 Feb 2020 05:11:39 -0800 Subject: [PATCH] win-capture/graphics-hook: Refactor mutex check OpenMutex doesn't return INVALID_HANDLE_VALUE, so there's no need to check for that. Also only call CloseHandle if the call was successful. --- plugins/win-capture/graphics-hook/graphics-hook.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/win-capture/graphics-hook/graphics-hook.h b/plugins/win-capture/graphics-hook/graphics-hook.h index ba6e0315c..7bfe3a057 100644 --- a/plugins/win-capture/graphics-hook/graphics-hook.h +++ b/plugins/win-capture/graphics-hook/graphics-hook.h @@ -149,8 +149,10 @@ static inline HMODULE load_system_library(const char *name) static inline bool capture_alive(void) { HANDLE handle = OpenMutexW(SYNCHRONIZE, false, keepalive_name); - CloseHandle(handle); - return handle != NULL && handle != INVALID_HANDLE_VALUE; + const bool success = handle != NULL; + if (success) + CloseHandle(handle); + return success; } static inline bool capture_active(void)