Browse Source

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.
jpark37 5 years ago
parent
commit
39dc64f0f8
1 changed files with 4 additions and 2 deletions
  1. 4 2
      plugins/win-capture/graphics-hook/graphics-hook.h

+ 4 - 2
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)