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

Commit 94574c4f authored by Huihong Luo's avatar Huihong Luo Committed by android-build-merger
Browse files

Merge "Fix bug #37284906, adb shell crashes on windows with invalid options....

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: e275043d
am: 4be54a46

Change-Id: Ic0d75aae1405badc8021835df498bcdbe0130088
parents c3398d9e 4be54a46
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -685,6 +685,10 @@ static int adb_shell(int argc, const char** argv) {


    // Parse shell-specific command-line options.
    // Parse shell-specific command-line options.
    argv[0] = "adb shell"; // So getopt(3) error messages start "adb shell".
    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.
    optind = 1; // argv[0] is always "shell", so set `optind` appropriately.
    int opt;
    int opt;
    while ((opt = getopt(argc, const_cast<char**>(argv), "+e:ntTx")) != -1) {
    while ((opt = getopt(argc, const_cast<char**>(argv), "+e:ntTx")) != -1) {