Merge pull request #2367 from gabfec/fix/term-width-oeverflow

Fix u16 mul overflow with big term width
This commit is contained in:
Mo Bitar 2026-03-14 17:29:10 +01:00 committed by GitHub
commit 415bf695be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -216,7 +216,9 @@ pub fn progress_bar<'a>(
stdout.write_all(PREFIX)?; stdout.write_all(PREFIX)?;
let width = term_width - WRAPPER_WIDTH; let width = term_width - WRAPPER_WIDTH;
let filled = (width * progress) / total; // Use u32 to prevent the intermediate multiplication from overflowing u16
let filled = (width as u32 * progress as u32) / total as u32;
let filled = filled as u16;
stdout.queue(SetForegroundColor(Color::Green))?; stdout.queue(SetForegroundColor(Color::Green))?;
for _ in 0..filled { for _ in 0..filled {