Skip to content

load gif System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument) #1530

Description

@3400442579

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument)
   at SixLabors.ImageSharp.Memory.Buffer2DRegion`1.Clear()
   at SixLabors.ImageSharp.Formats.Gif.GifDecoderCore.RestoreToBackground[TPixel](ImageFrame`1 frame)
   at SixLabors.ImageSharp.Formats.Gif.GifDecoderCore.ReadFrameColors[TPixel](Image`1& image, ImageFrame`1& previousFrame, Buffer2D`1 indices, ReadOnlySpan`1 colorTable, GifImageDescriptor& descriptor)
   at SixLabors.ImageSharp.Formats.Gif.GifDecoderCore.ReadFrame[TPixel](Image`1& image, ImageFrame`1& previousFrame)
   at SixLabors.ImageSharp.Formats.Gif.GifDecoderCore.Decode[TPixel](BufferedReadStream stream, CancellationToken cancellationToken)
   at SixLabors.ImageSharp.Formats.ImageDecoderUtilities.Decode[TPixel](IImageDecoderInternals decoder, Configuration configuration, Stream stream, Func`3 largeImageExceptionFactory)
   at SixLabors.ImageSharp.Formats.Gif.GifDecoder.Decode(Configuration configuration, Stream stream)
   at SixLabors.ImageSharp.Image.Decode(Stream stream, Configuration config)
   at SixLabors.ImageSharp.Image.WithSeekableStream[T](Configuration configuration, Stream stream, Func`2 action)
   at SixLabors.ImageSharp.Image.Load(Configuration configuration, Stream stream, IImageFormat& format)
   at SixLabors.ImageSharp.Image.Load(Configuration configuration, String path, IImageFormat& format)
   at SixLabors.ImageSharp.Image.Load(String path)
   at GifClient.ViewModels.CropViewModel.<>c__DisplayClass38_0.<SaveAsync>b__1() in E:\lq\GifAdvanced\src\BlueClient\ViewModels\CropViewModel.cs:line 177

Steps to Reproduce

 try
                {
                    Image gimage = Image.Load(sourceGif);
                    //gimage.Mutate(o => o.Crop(new Rectangle(Rect.X, Rect.Y, Rect.Width, Rect.Height)));
                    //gimage.SaveAsGif(fn);
                }

System Configuration

  • ImageSharp version: 1.0.2
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on): win10
  • .NET Framework version: 4.7.2
  • Additional information:

gif file:
aa

Activity

  1. JimBobSquarePants commented on Feb 2, 2021

    @JimBobSquarePants
    Member

    I'll take this. It's due to bad descriptor bounds in the image defining a rectangle outside of the frame bounds.

    Fix is easy enough. Use Rectangle.Intersect to sanitize the value before requesting a rectangle from the buffer.

  2. added a commit that references this issue on Feb 2, 2021
    ba115e1
  3. added a commit that references this issue on Mar 13, 2021
    f1a8e6e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions