From 0f278e2b59a073da05740ef51eacfc2497efffe3 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 10 Mar 2020 01:57:59 +0100 Subject: [PATCH] fix test failure related to #824 --- .../Jpeg/Components/Decoder/JpegComponentPostProcessor.cs | 5 ++++- .../Memory/Allocators/ArrayPoolMemoryAllocator.Buffer{T}.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) 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");