From f8734db1e18d2b1c0c8b51ccec69f54db15eed02 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 4 Dec 2022 18:22:38 +0100 Subject: [PATCH] Revert "Fix Development build issue with Flax.Build running in Development mode" This reverts commit 7e434932aefe6bf7105cc5ad58c671f70e85782d. --- Source/Engine/Platform/Windows/WindowsPlatform.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Engine/Platform/Windows/WindowsPlatform.cpp b/Source/Engine/Platform/Windows/WindowsPlatform.cpp index 56d84cd9c..1e4337016 100644 --- a/Source/Engine/Platform/Windows/WindowsPlatform.cpp +++ b/Source/Engine/Platform/Windows/WindowsPlatform.cpp @@ -1079,6 +1079,7 @@ int32 WindowsPlatform::RunProcess(const StringView& cmdLine, const StringView& w HANDLE stdOutRead = nullptr; HANDLE stdErrRead = nullptr; + Array attributeList; if (captureStdOut) { @@ -1100,7 +1101,8 @@ 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)Allocator::Allocate(bufferSize); + attributeList.Resize((int32)bufferSize); + startupInfoEx.lpAttributeList = (LPPROC_THREAD_ATTRIBUTE_LIST)attributeList.Get(); if (!InitializeProcThreadAttributeList(startupInfoEx.lpAttributeList, 1, 0, &bufferSize)) { LOG(Warning, "InitializeProcThreadAttributeList failed"); @@ -1124,6 +1126,9 @@ 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 @@ -1172,10 +1177,6 @@ ERROR_EXIT: { DeleteProcThreadAttributeList(startupInfoEx.lpAttributeList); } - if (environmentStr) - Allocator::Free(environmentStr); - if (startupInfoEx.lpAttributeList) - Allocator::Free(startupInfoEx.lpAttributeList); return result; }