Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e72c44b2 authored by Josh Gao's avatar Josh Gao
Browse files

adb: avoid freeing argv entries on Windows.

We assign string literals directly to argv[0], which leads to fun
explosions when we attempt to free  when the runtime can detect that
a bad free happened, which seems to happen reliably with lld.

Bug: http://b/110800681
Test: `adb shell true` on windows
Change-Id: Ica81e472c31686d80b58c41ff6d2b825baef06fb
parent 8958d7a1
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -2606,7 +2606,9 @@ extern "C" int main(int argc, char** argv);
extern "C" int wmain(int argc, wchar_t **argv) {
extern "C" int wmain(int argc, wchar_t **argv) {
    // Convert args from UTF-16 to UTF-8 and pass that to main().
    // Convert args from UTF-16 to UTF-8 and pass that to main().
    NarrowArgs narrow_args(argc, argv);
    NarrowArgs narrow_args(argc, argv);
    return main(argc, narrow_args.data());

    // Avoid destructing NarrowArgs: argv might have been mutated to point to string literals.
    _exit(main(argc, narrow_args.data()));
}
}


// Shadow UTF-8 environment variable name/value pairs that are created from
// Shadow UTF-8 environment variable name/value pairs that are created from