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

Fix bad NodeId limit checking. #91404

Merged
merged 1 commit into from
Dec 1, 2021

Conversation

nnethercote
Copy link
Contributor

Resolver::next_node_id converts a u32 to a usize (which is
possibly bigger), does a checked add, and then converts the result back
to a u32. The usize conversion completely subverts the checked add!

This commit removes the conversion to/from usize.

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 30, 2021
@rust-log-analyzer

This comment has been minimized.

`Resolver::next_node_id` converts a `u32` to a `usize` (which is
possibly bigger), does a checked add, and then converts the result back
to a `u32`. The `usize` conversion completely subverts the checked add!

This commit removes the conversion to/from `usize`.
@nnethercote nnethercote force-pushed the fix-bad-NodeId-limit-checking branch from 02d863c to e7ee823 Compare December 1, 2021 04:08
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. The use of usize in this code seems to trace back to the old pub fn reserve_node_ids(&mut self, count: usize) prior to 43a7405, which involved a usize addition. I guess the use of usize in that signature was intended to be convenient to callers. (reserve_node_ids(foo.len()) ?)

@dtolnay
Copy link
Member

dtolnay commented Dec 1, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Dec 1, 2021

📌 Commit e7ee823 has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 1, 2021
@dtolnay dtolnay assigned dtolnay and unassigned matthewjasper Dec 1, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 1, 2021
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#87160 (When recovering from a `:` in a pattern, use adequate AST pattern)
 - rust-lang#90985 (Use `get_diagnostic_name` more)
 - rust-lang#91087 (Remove all migrate.nll.stderr files)
 - rust-lang#91207 (Add support for LLVM coverage mapping format versions 5 and 6)
 - rust-lang#91298 (Improve error message for `E0659` if the source is not available)
 - rust-lang#91346 (Add `Option::inspect` and `Result::{inspect, inspect_err}`)
 - rust-lang#91404 (Fix bad `NodeId` limit checking.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4f252f1 into rust-lang:master Dec 1, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 1, 2021
@nnethercote nnethercote deleted the fix-bad-NodeId-limit-checking branch December 2, 2021 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants