Repository navigation
Fix unsafe pointer arithmetic/unsigned wrapping - #121
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes unsafe pointer arithmetic and unsigned wrapping issues in the Lorenzo predictor by transforming negative pointer subscript notation to explicit pointer arithmetic with proper parenthesization.
Key Changes:
- Converted negative subscript notation (
ptr[-expr]) to explicit pointer arithmetic with dereference (*(ptr - (expr))) - Added parentheses around addition operations to prevent intermediate unsigned wrapping
- Applied fix consistently across all Lorenzo predictor helper functions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
include/SZ3/utils/QuantOptimization.hpp |
Updated lorenzo_predict_3d function to use explicit pointer arithmetic with proper parenthesization for all 7 pointer offset calculations |
include/SZ3/predictor/LorenzoPredictor.hpp |
Updated helper functions prev1, prev2, prev3, and prev4 to use explicit pointer arithmetic with proper parenthesization for safe pointer offset calculations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
This was referenced Dec 8, 2025
ayzk
added a commit
that referenced
this pull request
Apr 26, 2026
Brings in upstream changes that don't touch docs/: * HDF5 target export improvements (#125, #126, #128) - SZ3::hdf5sz3 target now exposed in build + export trees - Cleanups in tools/H5Z-SZ3, mdz, sz3c CMakeLists * NixOS support: new default.nix (#129) * Lorenzo predictor pointer-arith UB fix (#121) - LorenzoPredictor.hpp + QuantOptimization.hpp: d[-i] -> *(d - i) to avoid size_t unsigned wrap-around .gitignore: union merge (master adds sz3_install / sz3_build / test; fz keeps tmp / .cache / docs/site/html / .claude). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.
Fix unsafe pointer arithmetic/unsigned wrapping in Lorenzo predictor. (#119)