Skip to content

fix: max_files integer underflow when set to zero #3348

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

unlimitedsola
Copy link

@unlimitedsola unlimitedsola commented Jul 26, 2025

Motivation

When max_files set to zero, rolling.rs:695 will cause integer underflow and panicking in debug build. In my opinion the API should prevent this from happening as "zero" is a valid usize value to pass in.

Solution

Currently, in release builds, if max_files is set to zero, it behaves just like u64::MAX on x86_64 platforms. Therefore, I decided to simply make zero == None, which should align with the existing behavior but without the panicking. I believe this can be considered as "non-breaking".

Feel free to advise if there a more preferred way of fixing this. Any help on how to provide tests would also be appreciated!

@unlimitedsola unlimitedsola requested a review from a team as a code owner July 26, 2025 10:52
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