-
-
Notifications
You must be signed in to change notification settings - Fork 851
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
PNG: Throw exception, if palette chunk is missing #2020
Conversation
@@ -21,6 +21,9 @@ public static void ThrowInvalidImageContentException(string errorMessage, Except | |||
[MethodImpl(InliningOptions.ColdPath)] | |||
public static void ThrowNoData() => throw new InvalidImageContentException("PNG Image does not contain a data chunk"); | |||
|
|||
[MethodImpl(InliningOptions.ColdPath)] | |||
public static void ThrowMissingPalette() => throw new InvalidImageContentException("PNG Image does not contain palette chunk"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a palette chunk
?
What's the current behavior? Out of range exception? The first referenced example is unopenable using conventional editors Edge and Chrome can open it displaying it as a 16x16 transparent png. I haven't tried the second but I wonder whether we should do the same? #2014 updates our Gif decoder to be more robust in this manner when decoding images whose color palette cannot be assigned. If we did the same for Png then the behavior for both decoders would then match browser behavior. |
System.NullReferenceException: 'Object reference not set to an instance of an object.' when accessing the empty palette span.
The png is corrupt and in my opinion throwing an exception and stating what's wrong with image is the right thing to do in such case. I dont think silently ignoring this would be good. |
Yeah, I've been flip-flopping around that. I'm gonna update my Gif PR to do what you do. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks! 👍
Prerequisites
Description
This PR changes the PNG decoder to throw an appropriate exception, if the palette chunk is missing.