Skip to content

Make PathHelper bounds checks explicit - #54

Merged
rameel merged 1 commit into
mainfrom
path-helper-bounds-checks
Oct 5, 2026
Merged

rameel merged 1 commit into
mainfrom
path-helper-bounds-checks

Conversation

@rameel

@rameel rameel commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Make bounds checks in PathHelper explicit in the AVX2, SSE2, and ARM64 paths.

This is a defensive refactoring, not a fix for an existing bug or reachable out-of-bounds memory access. Current callers supply strings, and CoreCLR's string length limit already prevents the original addition from overflowing.

The updated checks express the bounds requirements locally rather than relying on constraints enforced elsewhere.

Use subtraction-based bounds checks in the AVX2, SSE2, and ARM64 paths
to avoid relying on input size limits to prevent integer overflow.

Add a Debug.Assert before creating the partial-pattern span to
explicitly verify that its length is within the source string.

This is a defensive refactoring, not a fix for an existing bug or
reachable out-of-bounds memory access. Current callers supply strings,
and CoreCLR's string length limit already prevents the original addition
from overflowing. The change expresses the bounds requirements locally
rather than relying on constraints enforced elsewhere.
@rameel
rameel merged commit 06f86e2 into main Oct 5, 2026
3 checks passed
@rameel
rameel deleted the path-helper-bounds-checks branch October 5, 2026 15:12
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.

1 participant