Skip to content

Commit

Permalink
Maintenance: Fix compiler error C2362 in creatwth.cpp
Browse files Browse the repository at this point in the history
Compile error:

    error C2362: initialization of 'cchWrittenWideChar' is skipped by 'goto Cleanup'
  • Loading branch information
number201724 committed Dec 16, 2020
1 parent 90f54c2 commit 39aa864
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/creatwth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 39aa864

Please sign in to comment.