Merge pull request #4022 from Bond-009/arraypool

Fix incorrect usage of ArrayPool
This commit is contained in:
Anthony Lavado 2020-08-31 15:58:53 -04:00 committed by GitHub
commit 43a81366a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -130,6 +130,8 @@ namespace Jellyfin.Api.Helpers
private async Task<int> CopyToInternalAsync(Stream source, Stream destination, bool readAsync, CancellationToken cancellationToken)
{
var array = ArrayPool<byte>.Shared.Rent(IODefaults.CopyToBufferSize);
try
{
int bytesRead;
int totalBytesRead = 0;
@ -171,5 +173,10 @@ namespace Jellyfin.Api.Helpers
return totalBytesRead;
}
finally
{
ArrayPool<byte>.Shared.Return(array);
}
}
}
}