diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs index b91287fb3..d9fd9ac8b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs @@ -95,7 +95,10 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder Span colorBufferRow = this.ColorBuffer.GetRowSpan(yBuffer); Span blockRow = this.Component.SpectralBlocks.GetRowSpan(yBlock); - for (int xBlock = 0; xBlock < this.SizeInBlocks.Width; xBlock++) + // see: https://github.com/SixLabors/ImageSharp/issues/824 + int widthInBlocks = Math.Min(this.Component.SpectralBlocks.Width, this.SizeInBlocks.Width); + + for (int xBlock = 0; xBlock < widthInBlocks; xBlock++) { ref Block8x8 block = ref blockRow[xBlock]; int xBuffer = xBlock * this.blockAreaSize.Width; diff --git a/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.Buffer{T}.cs b/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.Buffer{T}.cs index 20ee645fd..f94359830 100644 --- a/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.Buffer{T}.cs +++ b/src/ImageSharp/Memory/Allocators/ArrayPoolMemoryAllocator.Buffer{T}.cs @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Memory protected override object GetPinnableObject() => this.Data; - [MethodImpl(MethodImplOptions.NoInlining)] + [MethodImpl(InliningOptions.ColdPath)] private static void ThrowObjectDisposedException() { throw new ObjectDisposedException("ArrayPoolMemoryAllocator.Buffer");