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
This commit is contained in:
Josh Gao 2019-06-10 12:48:34 -07:00
parent 8958d7a127
commit e72c44b24a

View file

@ -2606,7 +2606,9 @@ extern "C" int main(int argc, char** argv);
extern "C" int wmain(int argc, wchar_t **argv) {
// Convert args from UTF-16 to UTF-8 and pass that to main().
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