Add cross-dimension shape validation for diff prepend/append#1152
Conversation
There was a problem hiding this comment.
Pull request overview
Adds explicit cross-dimension (non-differencing dimension) shape validation for diff_2’s optional prepend/append arguments to prevent out-of-bounds assignment/memory corruption scenarios described in #1151.
Changes:
- Validate
size(prepend, 3-dim_) == size(x, 3-dim_)before usingprependin the internal workspace. - Validate
size(append, 3-dim_) == size(x, 3-dim_)before usingappendin the internal workspace.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…fix-diff2-bounds-check
5648b0c to
99a460a
Compare
|
hey @jalvesz according to the suggestion you have given I have raised a updated pr. Please have a look on this and suggest if there is requirement of any further changes |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1152 +/- ##
=======================================
Coverage 68.00% 68.00%
=======================================
Files 404 404
Lines 12935 12935
Branches 1392 1392
=======================================
Hits 8797 8797
Misses 4138 4138 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR introduces explicit cross-dimension shape validation for the prepend and append arguments in the diff_2 routine. Previously, passing an array with a mismatched non-differencing dimension bypassed shape checks, leading to potential bounds-check faults or silent memory corruption during the internal work array assignment. The update verifies size(array, 3 - dim_) == size(x, 3 - dim_) prior to workspace allocation, ensuring safe execution.
Solves #1151