fix: avoid char-boundary panic in NBReader::try_read#172
Merged
Conversation
epage
reviewed
May 13, 2026
298398d to
534e491
Compare
Contributor
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
Contributor
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. |
epage
reviewed
May 13, 2026
This comment was marked as duplicate.
This comment was marked as duplicate.
f9e11ce to
dffa1eb
Compare
Contributor
Author
|
Force-pushed without the thread::sleep, both tests now use a deadline-bounded poll on try_read so they finish as soon as the reader thread has pumped the two bytes. test suite still passes locally. |
dffa1eb to
740defa
Compare
Contributor
Author
|
Switched to a synchronous fixture that fills the buffer directly, no sleeps or polling. |
Contributor
|
Generally, I would be against breaking abstractions in tests but this might be the least bad option, so moving forward with it. We can always reevaluate in the future. |
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