From 6220cae6445d56d1d1356ecca38e66e76576d7ed Mon Sep 17 00:00:00 2001 From: Regis Boudinot Date: Sun, 8 Jun 2025 14:35:42 -0500 Subject: [PATCH] Check if terminal_width is less than offset and return 1 (see #244) (#245) --- CHANGELOG.md | 2 ++ src/main.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 265348c..9241c68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # unreleased +- Fix memory allocation bug when terminal width is less than 10, see #244 (@selfup) + ## Features ## Bugfixes diff --git a/src/main.rs b/src/main.rs index 2e32cff..24e8b7a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -362,7 +362,7 @@ fn run() -> Result<()> { } else { ((8 / group_size) * (base_digits * group_size + 1)) + 2 }; - if (terminal_width - offset) / col_width < 1 { + if (terminal_width.saturating_sub(offset)) / col_width < 1 { 1 } else { (terminal_width - offset) / col_width