Skip to content

Conversation

YoshikiTakashima
Copy link
Contributor

Fixes the out-of-bound UB in #52.

Looks like replacing dst.add with dst.wrapping_add is sufficient to stop UB from occurring, while passing all existing test cases.

Run
cargo miri test -- -Zmiri-disable-alignment-check -- big5::tests::test_big5_decode to confirm that the UB is fixed.

@hsivonen
Copy link
Owner

Thank you for looking into this.

Indeed, add here may compute a pointer that's outside the allocation bounds even if that pointer is never dereferenced, and wrapping_add is the right fix. The name of the wrapping_add methods is kinda weird for a pointer, but the documentation checks out.

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.

2 participants