diff --git a/Source/Engine/Platform/Windows/WindowsPlatform.cpp b/Source/Engine/Platform/Windows/WindowsPlatform.cpp index 6cec9376a..d732e8d2b 100644 --- a/Source/Engine/Platform/Windows/WindowsPlatform.cpp +++ b/Source/Engine/Platform/Windows/WindowsPlatform.cpp @@ -1100,7 +1100,7 @@ int32 WindowsPlatform::RunProcess(const StringView& cmdLine, const StringView& w SIZE_T bufferSize = 0; if (!InitializeProcThreadAttributeList(nullptr, 1, 0, &bufferSize) && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - startupInfoEx.lpAttributeList = (LPPROC_THREAD_ATTRIBUTE_LIST)Allocate(sizeof(byte) * bufferSize, 16); + startupInfoEx.lpAttributeList = (LPPROC_THREAD_ATTRIBUTE_LIST)Allocator::Allocate(bufferSize); if (!InitializeProcThreadAttributeList(startupInfoEx.lpAttributeList, 1, 0, &bufferSize)) { LOG(Warning, "InitializeProcThreadAttributeList failed"); @@ -1124,9 +1124,6 @@ int32 WindowsPlatform::RunProcess(const StringView& cmdLine, const StringView& w goto ERROR_EXIT; } - if (environmentStr) - Allocator::Free(environmentStr); - if (stdOutRead != nullptr) { // Keep reading std output and std error streams until process is running @@ -1176,6 +1173,8 @@ ERROR_EXIT: DeleteProcThreadAttributeList(startupInfoEx.lpAttributeList); Allocator::Free(startupInfoEx.lpAttributeList); } + if (environmentStr) + Allocator::Free(environmentStr); return result; }