Revert "Ensure executable paths are escaped on the Windows platform."

This reverts commit 49021a8fe8.

Reason for revert: Failure in Flutter roll

Original change's description:
> Ensure executable paths are escaped on the Windows platform.
>
> TEST=ci
>
> Change-Id: Ia6688aaa11d6898b20c92eb3a3a5510213c26d67
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439346
> Commit-Queue: Siva Annamalai <asiva@google.com>
> Reviewed-by: Jason Simmons <jsimmons@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I2408bb2fbe67c86ce2e57fc3f8c9c71476c82df3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439542
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Jason Simmons <jsimmons@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
Siva Annamalai
2025-07-09 13:28:21 -07:00
committed by Commit Queue
parent 077f16021f
commit 17fc8b5007
+6 -27
View File
@@ -492,8 +492,8 @@ class DartDev {
// Invoke the Dart VM directly bypassing dartdev.
static void InvokeDartVM(int argc, char** argv, bool argv_converted) {
auto dartvm_path = DartDev::ResolvedDartVmPath();
if (dartvm_path.get() == nullptr ||
!CheckForInvalidPath(dartvm_path.get())) {
char* exec_name = dartvm_path.get();
if (exec_name == nullptr || !CheckForInvalidPath(exec_name)) {
// Free environment if any.
Syslog::PrintErr("Unable to locate the Dart VM executable");
Options::Cleanup();
@@ -504,23 +504,12 @@ class DartDev {
err_msg[0] = '\0';
intptr_t num_args = argc + 2;
char** exec_argv = new char*[num_args];
#if defined(DART_HOST_OS_WINDOWS)
char* exec_name = StringUtilsWin::ArgumentEscape(dartvm_path.get());
#else
char* exec_name = Utils::StrDup(dartvm_path.get());
#endif
exec_argv[idx] = exec_name;
exec_argv[idx] = Utils::StrDup(exec_name);
const size_t kPathBufSize = PATH_MAX + 1;
char dart_path[kPathBufSize];
Platform::ResolveExecutablePathInto(dart_path, kPathBufSize);
idx += 1;
#if defined(DART_HOST_OS_WINDOWS)
char* dart_name = Utils::SCreate("--executable_name=%s", dart_path);
exec_argv[idx] = StringUtilsWin::ArgumentEscape(dart_name);
free(dart_name);
#else
exec_argv[idx] = Utils::SCreate("--executable_name=%s", dart_path);
#endif
for (intptr_t i = 1; i < argc; ++i) {
#if defined(DART_HOST_OS_WINDOWS)
exec_argv[i + idx] = StringUtilsWin::ArgumentEscape(argv[i]);
@@ -595,8 +584,8 @@ class DartDev {
static void RunExecResultCallback(Dart_CObject* message) {
result_ = DartDev_Result_RunExec;
auto dartvm_path = DartDev::ResolvedDartVmPath();
if (dartvm_path.get() == nullptr ||
!CheckForInvalidPath(dartvm_path.get())) {
char* exec_name = dartvm_path.get();
if (exec_name == nullptr || !CheckForInvalidPath(exec_name)) {
Syslog::PrintErr("Unable to locate the Dart VM executable");
Platform::Exit(kErrorExitCode);
}
@@ -640,11 +629,7 @@ class DartDev {
intptr_t idx = 0;
// Copy in name of the executable to run (should be the dart vm).
#if defined(DART_HOST_OS_WINDOWS)
script_name_ = StringUtilsWin::ArgumentEscape(dartvm_path.get());
#else
script_name_ = Utils::StrDup(dartvm_path.get());
#endif
script_name_ = Utils::StrDup(exec_name);
argv_[idx++] = script_name_;
// Copy in VM options if any.
// Copy in any vm options that need to be passed to the execed process.
@@ -656,13 +641,7 @@ class DartDev {
const size_t kPathBufSize = PATH_MAX + 1;
char dart_path[kPathBufSize];
Platform::ResolveExecutablePathInto(dart_path, kPathBufSize);
#if defined(DART_HOST_OS_WINDOWS)
char* dart_name = Utils::SCreate("--executable_name=%s", dart_path);
argv_[idx++] = StringUtilsWin::ArgumentEscape(dart_name);
free(dart_name);
#else
argv_[idx++] = Utils::SCreate("--executable_name=%s", dart_path);
#endif
}
if (mark_main_isolate_as_system_isolate) {
argv_[idx++] = Utils::StrDup("--mark_main_isolate_as_system_isolate");