Skip to content

Commit

Permalink
Fix MediaDownload overflow bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdunelm committed Jul 28, 2016
1 parent a4105e3 commit 49f2651
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private async Task<IDownloadProgress> DownloadCoreAsync(string url, Stream strea
var request = new HttpRequestMessage(HttpMethod.Get, uri.ToString());

// Number of bytes sent to the caller's stream.
int bytesReturned = 0;
long bytesReturned = 0;

try
{
Expand Down Expand Up @@ -275,7 +275,7 @@ private async Task<IDownloadProgress> DownloadCoreAsync(string url, Stream strea
// Send one chunk to the caller's stream.
int bytesToReturn = Math.Min(ChunkSize, buffer.Count);
await stream.WriteAsync(buffer.Data, 0, bytesToReturn, cancellationToken).ConfigureAwait(false);
checked { bytesReturned += bytesToReturn; }
bytesReturned += bytesToReturn;

buffer.RemoveFromFront(ChunkSize);
if (buffer.IsEmpty)
Expand Down

0 comments on commit 49f2651

Please sign in to comment.