Index: dart/sdk/lib/io/secure_socket.dart |
diff --git a/dart/sdk/lib/io/secure_socket.dart b/dart/sdk/lib/io/secure_socket.dart |
index 6261cf89fc27c6a5ee33475553bef1e59d0ec00c..f11355ae5a2dd5fb5c5e3213c207bbcc5eabe29f 100644 |
--- a/dart/sdk/lib/io/secure_socket.dart |
+++ b/dart/sdk/lib/io/secure_socket.dart |
@@ -1135,7 +1135,7 @@ class _ExternalBuffer { |
int bytesRead = 0; |
// Loop over zero, one, or two linear data ranges. |
while (bytesRead < bytes) { |
- int toRead = min(bytes, linearLength); |
+ int toRead = min(bytes - bytesRead, linearLength); |
result.setRange(bytesRead, |
bytesRead + toRead, |
data, |