fix: avoid char-boundary panic in NBReader::try_read#172
Open
SAY-5 wants to merge 2 commits into
Open
Conversation
epage
reviewed
May 13, 2026
| } | ||
|
|
||
| #[test] | ||
| fn test_try_read_multibyte_byte() { |
Contributor
There was a problem hiding this comment.
Our contrib guide asks for a particular commit structure. See also https://epage.github.io/dev/pr-style/#c-test
298398d to
534e491
Compare
Author
|
Split into a test commit that shows the panic on multi-byte input followed by the fix, per the contrib guide. |
534e491 to
f9e11ce
Compare
Author
|
Restructured per the c-test guide: the test commit now documents the panic with should_panic, and the fix commit drops should_panic and asserts the decoded chars. Pushed. |
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.
The internal buffer stores raw input bytes as latin-1 chars, so a byte >= 0x80 becomes a two-byte char and
drain(..1)could land off a char boundary and panic. Drain the first char by its UTF-8 length instead.Closes #32