Fix problem with socket input stream on MacOS when reading from tty.
This could cause an empty buffer to be added to an internal BufferList which violates our assumptions. R=sgjesse@google.com BUG= TEST= Review URL: https://chromiumcodereview.appspot.com//9348050 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4027 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -19,7 +19,13 @@ class _SocketInputStream implements SocketInputStream {
|
||||
}
|
||||
ByteArray buffer = new ByteArray(bytesToRead);
|
||||
int bytesRead = _socket.readList(buffer, 0, bytesToRead);
|
||||
if (bytesRead < bytesToRead) {
|
||||
if (bytesRead == 0) {
|
||||
// On MacOS when reading from a tty Ctrl-D will result in one
|
||||
// byte reported as available. Attempting to read it out will
|
||||
// result in zero bytes read. When that happens there is no data
|
||||
// which is indicated by a null return value.
|
||||
return null;
|
||||
} else if (bytesRead < bytesToRead) {
|
||||
ByteArray newBuffer = new ByteArray(bytesRead);
|
||||
newBuffer.setRange(0, bytesRead, buffer);
|
||||
return newBuffer;
|
||||
|
||||
Reference in New Issue
Block a user