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

Fixed string exif value corner case exception #2088

Merged
merged 6 commits into from
Apr 16, 2022

Conversation

br3aker
Copy link
Contributor

@br3aker br3aker commented Apr 14, 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

Closes #2087.

Given image from linked issue contains empty user comment tag which is written last. Allocated buffer is passed as Span which is sliced during different exif values rendering to the given buffer. This exact situation led to copying zero bytes to zero-length span aaaaand looks like .net treats empty spans with valid memory pointer as null pointer thus mentioned ArgumentNullException.

Fix is fairly simple: use spans instead of working with raw pointers without any fixed statements (love this performance side effect) and unsafe stuff, Encoding.GetBytes(ReadOnlySpan, Span) respects empty spans.

P.S.
Waiting for issue image usage approval from the issue author.

@br3aker
Copy link
Contributor Author

br3aker commented Apr 14, 2022

@JimBobSquarePants can you please advise where should I place the image from this issue?
I don't see any similar tests.

@antonfirsov
Copy link
Member

antonfirsov commented Apr 14, 2022

@br3aker I think adding yet another entry to BaselineTestJpegs or ProgressiveTestJpegs is good enough, we have a bunch of Exif regression cases there already.

@JimBobSquarePants
Copy link
Member

Yep, just add it to the collection there

@br3aker
Copy link
Contributor Author

br3aker commented Apr 15, 2022

Problem is that this image decodes correctly, it throws on encoding during writing exif profile.

@JimBobSquarePants
Copy link
Member

It鈥檚 cool, we did the same here.

#2059

@br3aker
Copy link
Contributor Author

br3aker commented Apr 15, 2022

Done, hope I got your idea right.

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

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

Looks perfect. Thanks 馃憤

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

Successfully merging this pull request may close these issues.

ArgumentNullException thrown when resizing jpg image
3 participants