Skip to content

Commit

Permalink
Check of subtract to avoid overflow error in ui.rs fn draw_messages (#88
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cleeyv authored Jul 20, 2021
1 parent f0484d4 commit 499d1bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed

- Fix formatting of phone number and update user name on start. ([#78])
- Fix an overflow error and crash by adding a subtraction check. ([#88])

[#78]: https://github.com/boxdot/gurk-rs/pull/78

Expand Down
9 changes: 8 additions & 1 deletion src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,14 @@ fn display_message(
}

let from = Span::styled(
textwrap::indent(&from, &" ".repeat(max_username_width - from.width())),
textwrap::indent(
&from,
&" ".repeat(
max_username_width
.checked_sub(from.width())
.unwrap_or_default(),
),
),
Style::default().fg(from_color),
);
let delimeter = Span::from(": ");
Expand Down

0 comments on commit 499d1bb

Please sign in to comment.