Skip to content

Commit

Permalink
Fix MediaDownload overflow bug (#778)
Browse files Browse the repository at this point in the history
Fixes #748
  • Loading branch information
chrisdunelm authored Jul 28, 2016
1 parent a4105e3 commit b7700e6
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 b7700e6

Please sign in to comment.