diff --git a/src/creatwth.cpp b/src/creatwth.cpp index c2819aff..54721e53 100644 --- a/src/creatwth.cpp +++ b/src/creatwth.cpp @@ -927,15 +927,18 @@ BOOL WINAPI DetourCreateProcessWithDllA(_In_opt_ LPCSTR lpApplicationName, lpCurrentDirectory, lpStartupInfo, &pi); + + if (!fResult) { + if (lpProcessInformation != NULL) { + ZeroMemory(lpProcessInformation, sizeof(*lpProcessInformation)); + } + return FALSE; + } if (lpProcessInformation != NULL) { CopyMemory(lpProcessInformation, &pi, sizeof(pi)); } - if (!fResult) { - return FALSE; - } - LPCSTR rlpDlls[2]; DWORD nDlls = 0; if (lpDllName != NULL) { @@ -985,12 +988,15 @@ BOOL WINAPI DetourCreateProcessWithDllW(_In_opt_ LPCWSTR lpApplicationName, lpStartupInfo, &pi); - if (lpProcessInformation) { - CopyMemory(lpProcessInformation, &pi, sizeof(pi)); - } - - if (!fResult) { + if (!fResult) { + if (lpProcessInformation != NULL) { + ZeroMemory(lpProcessInformation, sizeof(*lpProcessInformation)); + } return FALSE; + } + + if (lpProcessInformation != NULL) { + CopyMemory(lpProcessInformation, &pi, sizeof(pi)); } LPCSTR rlpDlls[2];