Merge "adb: avoid sign extension of shell return code."

This commit is contained in:
Treehugger Robot 2019-03-16 04:07:20 +00:00 committed by Gerrit Code Review
commit b5ac15a936
1 changed files with 4 additions and 1 deletions

View File

@ -295,7 +295,10 @@ int read_and_dump(int fd, bool use_shell_protocol = false,
callback->OnStderr(buffer_ptr, length);
break;
case ShellProtocol::kIdExit:
exit_code = protocol->data()[0];
// data() returns a char* which doesn't have defined signedness.
// Cast to uint8_t to prevent 255 from being sign extended to INT_MIN,
// which doesn't get truncated on Windows.
exit_code = static_cast<uint8_t>(protocol->data()[0]);
continue;
default:
continue;