Browse Source

win-capture: Refactor create_hook_info

jpark37 5 years ago
parent
commit
5c38c6455f
1 changed files with 11 additions and 4 deletions
  1. 11 4
      plugins/win-capture/graphics-hook-info.h

+ 11 - 4
plugins/win-capture/graphics-hook-info.h

@@ -109,9 +109,16 @@ struct hook_info {
 
 static inline HANDLE create_hook_info(DWORD id)
 {
-	wchar_t new_name[64];
-	_snwprintf(new_name, 64, L"%s%lu", SHMEM_HOOK_INFO, id);
+	HANDLE handle = NULL;
 
-	return CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0,
-				  sizeof(struct hook_info), new_name);
+	wchar_t new_name[64];
+	const int len = swprintf(new_name, _countof(new_name),
+				 SHMEM_HOOK_INFO L"%lu", id);
+	if (len > 0) {
+		handle = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL,
+					    PAGE_READWRITE, 0,
+					    sizeof(struct hook_info), new_name);
+	}
+
+	return handle;
 }