| Index: runtime/bin/socket.cc
|
| diff --git a/runtime/bin/socket.cc b/runtime/bin/socket.cc
|
| index fca6c54e253e47e33e465e818c68081f065d4a7e..fc528393b14b39fc7e746a2abce0084c065a8cd8 100644
|
| --- a/runtime/bin/socket.cc
|
| +++ b/runtime/bin/socket.cc
|
| @@ -111,19 +111,17 @@ void FUNCTION_NAME(Socket_Read)(Dart_NativeArguments args) {
|
| intptr_t bytes_read = Socket::Read(socket, buffer, length);
|
| if (bytes_read == length) {
|
| Dart_SetReturnValue(args, result);
|
| - } else if (bytes_read < length) {
|
| + } else if (bytes_read > 0) {
|
| + uint8_t* new_buffer = NULL;
|
| + Dart_Handle new_result = IOBuffer::Allocate(bytes_read, &new_buffer);
|
| + if (Dart_IsError(new_result)) Dart_PropagateError(new_result);
|
| + ASSERT(new_buffer != NULL);
|
| + memmove(new_buffer, buffer, bytes_read);
|
| + Dart_SetReturnValue(args, new_result);
|
| + } else if (bytes_read == 0) {
|
| // On MacOS when reading from a tty Ctrl-D will result in reading one
|
| // less byte then reported as available.
|
| - if (bytes_read == 0) {
|
| - Dart_SetReturnValue(args, Dart_Null());
|
| - } else {
|
| - uint8_t* new_buffer = NULL;
|
| - Dart_Handle new_result = IOBuffer::Allocate(bytes_read, &new_buffer);
|
| - if (Dart_IsError(new_result)) Dart_PropagateError(new_result);
|
| - ASSERT(new_buffer != NULL);
|
| - memmove(new_buffer, buffer, bytes_read);
|
| - Dart_SetReturnValue(args, new_result);
|
| - }
|
| + Dart_SetReturnValue(args, Dart_Null());
|
| } else {
|
| ASSERT(bytes_read == -1);
|
| Dart_SetReturnValue(args, DartUtils::NewDartOSError());
|
|
|