Browse Source

Add more cancellation checks

pull/2276/head
James Jackson-South 4 years ago
parent
commit
a58e6ff53d
  1. 2
      src/ImageSharp/IO/BufferedReadStream.cs

2
src/ImageSharp/IO/BufferedReadStream.cs

@ -90,6 +90,7 @@ internal sealed class BufferedReadStream : Stream
set set
{ {
Guard.MustBeGreaterThanOrEqualTo(value, 0, nameof(this.Position)); Guard.MustBeGreaterThanOrEqualTo(value, 0, nameof(this.Position));
this.cancellationToken.ThrowIfCancellationRequested();
// Only reset readBufferIndex if we are out of bounds of our working buffer // Only reset readBufferIndex if we are out of bounds of our working buffer
// otherwise we should simply move the value by the diff. // otherwise we should simply move the value by the diff.
@ -262,6 +263,7 @@ internal sealed class BufferedReadStream : Stream
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
private void FillReadBuffer() private void FillReadBuffer()
{ {
this.cancellationToken.ThrowIfCancellationRequested();
Stream baseStream = this.BaseStream; Stream baseStream = this.BaseStream;
if (this.readerPosition != baseStream.Position) if (this.readerPosition != baseStream.Position)
{ {

Loading…
Cancel
Save