Repository navigation
Throw InvalidDataException when Skia cannot decode an image - #155
Open
Adamstuhltrager wants to merge 1 commit into
Open
Adamstuhltrager wants to merge 1 commit into
Adamstuhltrager wants to merge 1 commit into
Conversation
SKCodec.Create returns null for data Skia does not recognise, and SKBitmap.Decode returns null when the codec fails to produce pixels, for example on a truncated progressive JPEG. Both were dereferenced without a check, so callers saw a NullReferenceException with no indication that the input was at fault. Route codec creation and bitmap decoding through helpers that throw an InvalidDataException with a descriptive message instead, and throw FileNotFoundException up front for a missing file. Add tests covering unrecognised data, a truncated progressive JPEG fixture and a missing file for every public overload. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SKCodec.Createreturns null for data Skia does not recognise, andSKBitmap.Decodereturns null when the codec fails to produce pixels (for example a truncated progressive JPEG, where the header is readable butGetPixelsreturnsInvalidInput). Both were dereferenced without a check, so callers get aNullReferenceExceptionfrom inside the encoder with no hint that the input was at fault. Jellyfin users hit this on every library scan for any corrupt poster or logo; see jellyfin/jellyfin#12106 and jellyfin/jellyfin#3687, which carry the same stack trace.This routes codec creation and bitmap decoding through helpers that throw
InvalidDataExceptionwith a descriptive message, throwsFileNotFoundExceptionup front for a missing file, and documents both on the public overloads.Tests cover unrecognised data, a truncated progressive JPEG fixture (459 bytes, generated from a gradient) and a missing file, for all four public overloads. The SkiaSharp test project now copies
TestData/to the output directory.🤖 Generated with Claude Code