Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check whether out of bound when access a known length array with a constant index #11998

Merged
merged 2 commits into from Dec 22, 2023

Conversation

cocodery
Copy link
Contributor

fixes Issue#11762

Issue#11762 points that Array references with known length are not flagged when indexed out of bounds.

To fix this problem, it is needed to add check for Expr::Index. We expand this issue include reference and direct accessing a array.

When we access a array with a constant index off, and already know the length size, if off >= size, these code will throw an error, instead rustc's lint checking them or runtime panic happening.

changelog: [out_of_bound_indexing]: Add check for illegal accessing known length array with a constant index

@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2023

r? @llogiq

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 22, 2023
@llogiq
Copy link
Contributor

llogiq commented Dec 22, 2023

Looks good to me.

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 22, 2023

📌 Commit 18eb406 has been approved by llogiq

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Dec 22, 2023

⌛ Testing commit 18eb406 with merge e0b25c5...

@bors
Copy link
Collaborator

bors commented Dec 22, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: llogiq
Pushing e0b25c5 to master...

@bors bors merged commit e0b25c5 into rust-lang:master Dec 22, 2023
5 checks passed
@cocodery cocodery deleted the fix/issue11762 branch December 23, 2023 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

out_of_bounds_indexing doesn't apply to array references
4 participants