diff --git a/src/OneScript.StandardLibrary/Net/TCPClient.cs b/src/OneScript.StandardLibrary/Net/TCPClient.cs index 44abe36a7..ae8b940dc 100644 --- a/src/OneScript.StandardLibrary/Net/TCPClient.cs +++ b/src/OneScript.StandardLibrary/Net/TCPClient.cs @@ -81,7 +81,11 @@ private MemoryStream ReadAllData(NetworkStream source, int limit) int numberOfBytesRead = source.Read(readBuffer, 0, portion); ms.Write(readBuffer, 0, numberOfBytesRead); if (useLimit) - limit -= numberOfBytesRead; + { + limit -= numberOfBytesRead; + if (limit <= 0) + break; + } } while (source.DataAvailable); if(ms.Length > 0)