Repository navigation
Fix undefined behaviour in GET macros due to signed shift - #1035
Merged
Merged
Conversation
There is a comment about an odd integer promotion. This is because unsigned char promotes to signed int, legitimately as there is no truncation, but the shift should be done on an unsigned value to avoid shifting bits into the sign.
There was a problem hiding this comment.
🟢 Approval recommended
The casts correctly eliminate signed-shift undefined behavior, and the sanitizer test counts and configurations remain consistent.
0 open findings
What changed in this PR
Fixes undefined behavior in internal offset-reading macros by ensuring shifts operate on unsigned values.
Changes:
- Casts code units before shifts in
GETandGET2. - Expands sanitizer testing across minimum and maximum link sizes.
- Clarifies macro and test documentation.
| File | Description |
|---|---|
src/pcre2_intmodedep.h |
Makes offset reads and writes explicitly unsigned and width-safe. |
maint/ManyConfigTests |
Runs ASan and UBSan tests with link sizes 2 and 4. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
There is a comment about an odd integer promotion. This is because unsigned char promotes to signed int, legitimately as there is no truncation, but the shift should be done on an unsigned value to avoid shifting bits into the sign.