Skip to content

NullReferenceException while loading image #2948

Open
@ZubanovNikita

Description

@ZubanovNikita

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

ImageSharp version

3.1.10

Other ImageSharp packages and versions

3.1.10

Environment (Operating system, version and so on)

Windows 10 Pro, version 2009

.NET Framework version

.net 9.0

Description

If the image is corrupted - the "SOS" marker is missing - NullReferenceException is thrown when loading the image. Although a more appropriate error would be ImageFormatException, I suppose.

Steps to Reproduce

  1. Download any picture.
  2. Transform to bytes.
  3. Remove all SOS markers.
  4. Initialize stream with bytes.
  5. Try to load image from stream.
  6. NRE is thrown instead of more appropriate exception.

Test project to reproduce this issue: SixLabors.NREWhileLoadingImage.zip

Images

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions