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