Fixed string exif value corner case exception#2088
Merged
JimBobSquarePants merged 6 commits intoSixLabors:mainfrom Apr 16, 2022
Merged
Fixed string exif value corner case exception#2088JimBobSquarePants merged 6 commits intoSixLabors:mainfrom
JimBobSquarePants merged 6 commits intoSixLabors:mainfrom
Conversation
Contributor
Author
|
@JimBobSquarePants can you please advise where should I place the image from this issue? |
Member
|
@br3aker I think adding yet another entry to BaselineTestJpegs or ProgressiveTestJpegs is good enough, we have a bunch of Exif regression cases there already. |
Member
|
Yep, just add it to the collection there |
Contributor
Author
|
Problem is that this image decodes correctly, it throws on encoding during writing exif profile. |
Member
|
It’s cool, we did the same here. |
Contributor
Author
|
Done, hope I got your idea right. |
JimBobSquarePants
approved these changes
Apr 16, 2022
Member
JimBobSquarePants
left a comment
There was a problem hiding this comment.
Looks perfect. Thanks 👍
This was referenced Apr 21, 2022
1 task
This was referenced Jul 23, 2025
This was referenced Jul 30, 2025
This was referenced Sep 23, 2025
This was referenced Oct 3, 2025
This was referenced Feb 3, 2026
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.
Prerequisites
Description
Closes #2087.
Given image from linked issue contains empty user comment tag which is written last. Allocated buffer is passed as
Spanwhich 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 mentionedArgumentNullException.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.