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

fix(Rect): fixes underflow in the Rect::intersection method #678

Merged

Conversation

Valentin271
Copy link
Member

From @bugnano in #677

The Rect.intersection method contained the simple - operator, which panics on underflow.
This is strange, as all the other methods in Rect use saturating_add and saturating_sub.
So I changed the - operation to a saturating_sub, so that Rect.intersection never panics.

With a signed commit and a unit test.

Copy link

codecov bot commented Dec 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2a87251) 90.9% compared to head (604d9d4) 90.9%.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #678   +/-   ##
=====================================
  Coverage   90.9%   90.9%           
=====================================
  Files         42      42           
  Lines      12671   12678    +7     
=====================================
+ Hits       11519   11526    +7     
  Misses      1152    1152           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@orhun
Copy link
Sponsor Member

orhun commented Dec 9, 2023

Not sure if we need more unit tests for this, let's wait for review from other maintainers.

@Valentin271 Valentin271 force-pushed the fix/rect-underflow-intersection branch from 3bd0e15 to 604d9d4 Compare December 9, 2023 12:26
Copy link
Member

@joshka joshka left a comment

Choose a reason for hiding this comment

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

Seems like enough tests to me

@joshka joshka merged commit f69d57c into ratatui-org:main Dec 9, 2023
33 checks passed
@Valentin271 Valentin271 deleted the fix/rect-underflow-intersection branch December 9, 2023 14:28
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.

None yet

3 participants