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
[fuzz-test] Arithmetic overflow occurs while using API Buffer::empty() #517
Comments
That might be a reasonable addition.
While I don't think any terminal can get this big and actually function, maybe also providing a checked version of this function does make some sense: |
Area should possibly just be u32 or perhaps usize instead to allow for larger dimensions. Note: I haven't checked the history of this decision to understand if there is a good rationale for this. It seems intentional that we avoid allocating more than u16::MAX for any Rect as noted by the ::new() function. |
Adding assert still meaningful, as arith overflow does not panic by rustc on release build. Plus, in this particular case, modifying field of |
TIL (thanks).
By definition, u16 * u16 can't overflow u32 / usize. Regardless, the sort of use case where area() is called from is more likely to be for 0 checks rather than > u16::MAX checks. I think a better stopgap solution would be to use saturating ops rather than panicking.
There's a lot of reasonable uses in apps to want to do e.g.: let sub_area = Rect { x: area.x + 1, width: area.x - 1, ..area }; |
Using saturating ops seems best fit for this case. Thanks. I'll come up with pr for this issue and #520 |
Can you please re-run the fuzzer with the updated code to check that this is fixed and there aren't other issues in the same area? |
This has been fixed on #523 , no other issues has been found. |
Description
I executed fuzzing to test
tui-0.19.0
APIs. This reproduced onratatui
as well.To Reproduce
Expected behavior
Adding assert statement or modifying to use checked operation would resolve this issue.
The text was updated successfully, but these errors were encountered: