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

[BUG] usize overflow on big cache capacity #25

Closed
GrandChaman opened this issue Aug 26, 2021 · 2 comments · Fixed by #28
Closed

[BUG] usize overflow on big cache capacity #25

GrandChaman opened this issue Aug 26, 2021 · 2 comments · Fixed by #28
Assignees
Labels
bug Something isn't working
Milestone

Comments

@GrandChaman
Copy link

Hello,

First of all thank you for the very nice work !

There seems to be a multiply overflow that could be handled at the line referenced below.

let skt_capacity = usize::max(max_capacity * 32, 100);

This could be done either by returning an error type, or by maxing the value of the cache capacity to usize::max_value() / 32

@tatsuya6502 tatsuya6502 added the bug Something isn't working label Aug 26, 2021
@tatsuya6502
Copy link
Member

Thank you for reporting. You are right. The overflow will occur especially when usize is 32 bit or smaller. I will set a reasonable max value to skt_capacity to avoid the overflow.

@tatsuya6502 tatsuya6502 linked a pull request Aug 28, 2021 that will close this issue
@tatsuya6502 tatsuya6502 self-assigned this Aug 28, 2021
@tatsuya6502 tatsuya6502 added this to the v0.5.2 milestone Aug 28, 2021
@tatsuya6502
Copy link
Member

This has been addressed by #28. I will release Moka v0.5.2 soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants