From: David Nissimoff Date: Sat, 18 Nov 2017 15:11:06 +0000 (-0800) Subject: Fix #15057 MemoryStream.CopyToAsync calls Write / WriteAsync with count=0 (#15070) X-Git-Tag: accepted/tizen/base/20180629.140029~539 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02e499eb04d42d35943ce7a78f078c8a16aedb3f;p=platform%2Fupstream%2Fcoreclr.git Fix #15057 MemoryStream.CopyToAsync calls Write / WriteAsync with count=0 (#15070) --- diff --git a/src/mscorlib/src/System/IO/MemoryStream.cs b/src/mscorlib/src/System/IO/MemoryStream.cs index d2fd83d..6039dc7 100644 --- a/src/mscorlib/src/System/IO/MemoryStream.cs +++ b/src/mscorlib/src/System/IO/MemoryStream.cs @@ -541,6 +541,10 @@ namespace System.IO Int32 pos = _position; Int32 n = InternalEmulateRead(_length - _position); + // If we were already at or past the end, there's no copying to do so just quit. + if (n == 0) + return Task.CompletedTask; + // If destination is not a memory stream, write there asynchronously: MemoryStream memStrDest = destination as MemoryStream; if (memStrDest == null)