Merge "Fix bug #37284906, adb shell crashes on windows with invalid options. For example, "adb.exe shell -list" crashes without this fix. Test: adb.exe shell -list-packages"

am: e275043d38

Change-Id: Idd5574dc504eaa2b740847c8baed795507b9d180
This commit is contained in:
Huihong Luo 2017-08-18 14:42:21 +00:00 committed by android-build-merger
commit 4be54a4622
1 changed files with 4 additions and 0 deletions

View File

@ -685,6 +685,10 @@ static int adb_shell(int argc, const char** argv) {
// Parse shell-specific command-line options.
argv[0] = "adb shell"; // So getopt(3) error messages start "adb shell".
#ifdef _WIN32
// fixes "adb shell -l" crash on Windows, b/37284906
__argv = const_cast<char**>(argv);
#endif
optind = 1; // argv[0] is always "shell", so set `optind` appropriately.
int opt;
while ((opt = getopt(argc, const_cast<char**>(argv), "+e:ntTx")) != -1) {