From 39aa864d2985099c8d847e29a5fb86618039b9c4 Mon Sep 17 00:00:00 2001 From: number201724 Date: Thu, 17 Dec 2020 07:07:34 +0800 Subject: [PATCH] Maintenance: Fix compiler error C2362 in creatwth.cpp Compile error: error C2362: initialization of 'cchWrittenWideChar' is skipped by 'goto Cleanup' --- src/creatwth.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/creatwth.cpp b/src/creatwth.cpp index 145b2822..f7b51f40 100644 --- a/src/creatwth.cpp +++ b/src/creatwth.cpp @@ -1280,6 +1280,8 @@ BOOL WINAPI DetourProcessViaHelperDllsW(_In_ DWORD dwTargetPid, WCHAR szCommand[MAX_PATH]; PDETOUR_EXE_HELPER helper = NULL; HRESULT hr; + WCHAR szDllName[MAX_PATH]; + int cchWrittenWideChar; DWORD nLen = GetEnvironmentVariableW(L"WINDIR", szExe, ARRAYSIZE(szExe)); DETOUR_TRACE(("DetourProcessViaHelperDlls(pid=%d,dlls=%d)\n", dwTargetPid, nDlls)); @@ -1310,8 +1312,8 @@ BOOL WINAPI DetourProcessViaHelperDllsW(_In_ DWORD dwTargetPid, //for East Asia languages and so on, like Chinese, print format with "%hs" can not work fine before user call _tsetlocale(LC_ALL,_T(".ACP")); //so we can't use "%hs" in format string, because the dll that contain this code would inject to any process, even not call _tsetlocale(LC_ALL,_T(".ACP")) before - WCHAR szDllName[MAX_PATH]; - int cchWrittenWideChar = MultiByteToWideChar(CP_ACP, 0, &helper->rDlls[0], -1, szDllName, ARRAYSIZE(szDllName)); + + cchWrittenWideChar = MultiByteToWideChar(CP_ACP, 0, &helper->rDlls[0], -1, szDllName, ARRAYSIZE(szDllName)); if (cchWrittenWideChar >= ARRAYSIZE(szDllName) || cchWrittenWideChar <= 0) { goto Cleanup; }