From ff32ae804e7d411c66d48891ba5a7a34009ae766 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 2 Jun 2022 12:03:33 -0700 Subject: [PATCH] manual fuzzing with cat /dev/random refs: https://github.com/wez/wezterm/issues/2067 --- termwiz/src/escape/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/termwiz/src/escape/mod.rs b/termwiz/src/escape/mod.rs index 8f7920fa4..52e705cc7 100644 --- a/termwiz/src/escape/mod.rs +++ b/termwiz/src/escape/mod.rs @@ -258,19 +258,19 @@ impl Sixel { // Compute it by evaluating the sixel data let mut max_x = 0; let mut max_y = 0; - let mut x = 0; - let mut rows = 1; + let mut x: u32 = 0; + let mut rows: u32 = 1; for d in &self.data { match d { SixelData::Data(_) => { max_y = max_y.max(rows * 6); - x += 1; + x = x.saturating_add(1); max_x = max_x.max(x); } SixelData::Repeat { repeat_count, .. } => { max_y = max_y.max(rows * 6); - x += repeat_count; + x = x.saturating_add(*repeat_count); max_x = max_x.max(x); } SixelData::SelectColorMapEntry(_) @@ -279,7 +279,7 @@ impl Sixel { SixelData::NewLine => { max_x = max_x.max(x); x = 0; - rows += 1; + rows = rows.saturating_add(1); } SixelData::CarriageReturn => { max_x = max_x.max(x);