Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip invalid markers during jpeg decoding #2147

Merged

Conversation

br3aker
Copy link
Contributor

@br3aker br3aker commented Jun 5, 2022

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 馃懏.
  • I have provided test coverage for my change (where applicable)

Description

Fixes #2136

Given image contained extra unused bytes right at the end of the SOS segment containing RST markers and 0xFF00 sequences. This lead to non-SOS parser to count them as valid markers and failed with exception. With this PR jpeg decoder now skips any invalid markers during non-SOS parsing so we can at least give the user something instead of exception.

@@ -491,7 +488,8 @@ internal void ParseStream(BufferedReadStream stream, SpectralConverter spectralC
}

// Read on.
fileMarker = FindNextFileMarker(this.markerBuffer, stream);
fileMarker = FindNextFileMarker(stream);
Console.WriteLine($"Found marker: {fileMarker.Marker} at {fileMarker.Position}");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Console.WriteLine is probably a leftover from debugging

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups!

Copy link
Collaborator

@brianpopow brianpopow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants