New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image.Load throws NullReferenceException #797

Closed
Metalnem opened this Issue Dec 24, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@Metalnem
Copy link

Metalnem commented Dec 24, 2018

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.

@dlemstra

This comment has been minimized.

Copy link
Member

dlemstra commented Dec 25, 2018

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

@Metalnem

This comment has been minimized.

Copy link

Metalnem commented Dec 25, 2018

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 

jongleur1983 added a commit to jongleur1983/ImageSharp that referenced this issue Jan 4, 2019

@jongleur1983

This comment has been minimized.

Copy link
Contributor

jongleur1983 commented Jan 4, 2019

@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...

@Metalnem

This comment has been minimized.

Copy link

Metalnem commented Jan 4, 2019

That's right, the image is invalid!

jongleur1983 added a commit to jongleur1983/ImageSharp that referenced this issue Jan 4, 2019

JimBobSquarePants added a commit that referenced this issue Jan 6, 2019

Merge pull request #801 from jongleur1983/797-LoadThrowsNRE-bySharpFuzz
#797 throw ImageFormatException when no StartOfFrame marker is found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment