From a58e6ff53d6f61f283446368cc8ee0dbc4020e4c Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 8 Dec 2022 11:16:09 +1000 Subject: [PATCH] Add more cancellation checks --- src/ImageSharp/IO/BufferedReadStream.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ImageSharp/IO/BufferedReadStream.cs b/src/ImageSharp/IO/BufferedReadStream.cs index 9200dbf7ff..efa8f6f4be 100644 --- a/src/ImageSharp/IO/BufferedReadStream.cs +++ b/src/ImageSharp/IO/BufferedReadStream.cs @@ -90,6 +90,7 @@ internal sealed class BufferedReadStream : Stream set { Guard.MustBeGreaterThanOrEqualTo(value, 0, nameof(this.Position)); + this.cancellationToken.ThrowIfCancellationRequested(); // Only reset readBufferIndex if we are out of bounds of our working buffer // otherwise we should simply move the value by the diff. @@ -262,6 +263,7 @@ internal sealed class BufferedReadStream : Stream [MethodImpl(MethodImplOptions.NoInlining)] private void FillReadBuffer() { + this.cancellationToken.ThrowIfCancellationRequested(); Stream baseStream = this.BaseStream; if (this.readerPosition != baseStream.Position) {