8

Fix underflow in `manual_split_once` lint by pr2502 · Pull Request #8250 · rust-...

 2 years ago
source link: https://github.com/rust-lang/rust-clippy/pull/8250
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

pr2502 commented on Jan 8

edited by giraffate

Hi, a friend found clippy started crashing on a suspiciously large allocation of u64::MAX memory on their code.

The mostly minimized repro is:

fn _f01(title: &str) -> Option<()> {
    let _ = title[1..].splitn(2, '[').next()?;
    Some(())
}

The underflow happens in this case on line 57 of the patch but I've changed the other substraction to saturating as well since it could potentially cause the same issue.

I'm not sure where to put a regression test, or if it's even worth for such a thing.

Aside, has it been considered before to build clippy with overflow checks enabled?

changelog: fix ICE of underflow in manual_split_once lint


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK