Skip to content

Fix out of bounds access in quartiles #1855

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

Merged
merged 1 commit into from
Mar 14, 2024
Merged

Fix out of bounds access in quartiles #1855

merged 1 commit into from
Mar 14, 2024

Conversation

Zentrik
Copy link
Contributor

@Zentrik Zentrik commented Mar 14, 2024

For an example consider len=2, h1_end underflows and h2_begin = 2.

@Kobzol
Copy link
Contributor

Kobzol commented Mar 14, 2024

Hi, did you encounter a crash locally with the original code? 🤔

@Zentrik
Copy link
Contributor Author

Zentrik commented Mar 14, 2024

Yes when I set NUM_PREVIOUS_COMMITS to 3, I assume pcs then had length 2 and so there was a panic on let q1 = median(&pcs[..=h1_end]);

@Kobzol
Copy link
Contributor

Kobzol commented Mar 14, 2024

Hmm, yeah, but the code uses NUM_PREVIOUS_COMMITS = 30, so it doesn't really have to deal with this. That being said, the change is simple enough, so why not :)

@Kobzol
Copy link
Contributor

Kobzol commented Mar 14, 2024

Could you please just squash the commits into a single one? (Let me know if you want help with that).

For an example consider len=2, h1_end underflows and h2_begin = 2.
@Zentrik
Copy link
Contributor Author

Zentrik commented Mar 14, 2024

I presume if len=0 this will still crash actually, I could add some code to in that case default to the DEFAULT_SIGNIFICANCE_THRESHOLD if you want.

Copy link
Contributor

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

No, that's fine. Thanks!

@Kobzol Kobzol merged commit bf37180 into rust-lang:master Mar 14, 2024
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.

2 participants