Skip to content

Image.Load throws NullReferenceException #797

Description

@Metalnem

Image.Load throws a NullReferenceException when loading the image from the attached archive. You can run the following code to reproduce it (the path variable should contain the path to the extracted file):

Image.Load(path);

Found via SharpFuzz.

Activity

  1. dlemstra commented on Dec 25, 2018

    @dlemstra
    Member

    @Metalnem It looks like your message is automated/auto generated. Would it be possible to also include a stack trace?

  2. Metalnem commented on Dec 25, 2018

    @Metalnem
    Author

    Sorry if I'm looking automated :) Anyway, here's the stack trace:

    An unhandled exception of type 'System.NullReferenceException' occurred in SixLabors.ImageSharp.dll: 'Object reference not set to an instance of an object.'
       at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.ProcessStartOfScanMarker()
       at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.ParseStream(Stream stream, Boolean metadataOnly)
       at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.Decode[TPixel](Stream stream)
       at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoder.Decode[TPixel](Configuration configuration, Stream stream)
       at SixLabors.ImageSharp.Image.Decode[TPixel](Stream stream, Configuration config)
       at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, Stream stream, IImageFormat& format)
       at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, String path)
       at SixLabors.ImageSharp.Run.Program.Main(String[] args) in 
    
  3. added a commit that references this issue on Jan 4, 2019
  4. jongleur1983 commented on Jan 4, 2019

    @jongleur1983
    Contributor

    @Metalnem Just to confirm I understand it right: The image in fact is invalid, right?

    According to the file header it's a JPEG (Jfif) file, and I can reproduce the bug, but the image can't be opened by the windows 10 image viewer, paint, paint.net or Gimp.

    So we're going to throw an ImageFormatException stating that there is no readable SOF0 marker in this case.

    PR incoming in a few minutes...

  5. Metalnem commented on Jan 4, 2019

    @Metalnem
    Author

    That's right, the image is invalid!

  6. added a commit that references this issue on Jan 4, 2019
  7. added a commit that references this issue on Jan 6, 2019
  8. added 2 commits that reference this issue on Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions