diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 8f5cc3b5c8..2f6b45aff9 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -535,7 +535,8 @@ private void RestoreToBackground(ImageFrame frame) return; } - Buffer2DRegion pixelRegion = frame.PixelBuffer.GetRegion(this.restoreArea.Value); + var interest = Rectangle.Intersect(frame.Bounds(), this.restoreArea.Value); + Buffer2DRegion pixelRegion = frame.PixelBuffer.GetRegion(interest); pixelRegion.Clear(); this.restoreArea = null; diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index a115b12109..058d669d40 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -171,6 +171,17 @@ public void CanDecodeIntermingledImages() } } + // https://github.com/SixLabors/ImageSharp/issues/1503 + [Theory] + [WithFile(TestImages.Gif.Issues.Issue1530, PixelTypes.Rgba32)] + public void Issue1530_BadDescriptorDimensions(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + image.DebugSaveMultiFrame(provider); + image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact); + } + // https://github.com/SixLabors/ImageSharp/issues/405 [Theory] [WithFile(TestImages.Gif.Issues.BadAppExtLength, PixelTypes.Rgba32)] @@ -181,6 +192,7 @@ public void Issue405_BadApplicationExtensionBlockLength(TestImageProvide using (Image image = provider.GetImage()) { image.DebugSave(provider); + image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index b5dd5b2bb1..ac9d6422aa 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -416,6 +416,7 @@ public static class Issues public const string BadAppExtLength_2 = "Gif/issues/issue405_badappextlength252-2.gif"; public const string BadDescriptorWidth = "Gif/issues/issue403_baddescriptorwidth.gif"; public const string Issue1505 = "Gif/issues/issue1505_argumentoutofrange.png"; + public const string Issue1530 = "Gif/issues/issue1530.gif"; } public static readonly string[] All = { Rings, Giphy, Cheers, Trans, Kumin, Leo, Ratio4x1, Ratio1x4 }; diff --git a/tests/Images/External b/tests/Images/External index 346070e5ba..1df6516244 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit 346070e5ba538f1a3bbafc0ea7367404c5f8c9ab +Subproject commit 1df65162448996332449387a46da942e181043c8 diff --git a/tests/Images/Input/Gif/issues/issue1530.gif b/tests/Images/Input/Gif/issues/issue1530.gif new file mode 100644 index 0000000000..47b71718f7 Binary files /dev/null and b/tests/Images/Input/Gif/issues/issue1530.gif differ