From fe78ca02a3ca4a08768af65417921394eb4e0e1f Mon Sep 17 00:00:00 2001 From: technomancer Date: Thu, 29 Oct 2026 08:10:54 -0700 Subject: [PATCH] vnc: fix overflow in the ZRLE test picture The noise pattern multiplied u32s with overflow, which panics in debug builds. Use wrapping_mul; the picture is unchanged. Co-Authored-By: Claude Opus 5.5 --- src/vnc/encode.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vnc/encode.rs b/src/vnc/encode.rs index 907b2bdf8..85773ef30 100644 --- a/src/vnc/encode.rs +++ b/src/vnc/encode.rs @@ -392,7 +392,7 @@ mod tests { for y in 0..h { for x in 0..w { px[y * w + x] = match (x / 40, y / 30) { - (0, _) => 0xff00_0000 | ((x * 7 + y * 13) as u32 * 2_654_435_761) & 0xff_ffff, // noise + (0, _) => 0xff00_0000 | ((x * 7 + y * 13) as u32).wrapping_mul(2_654_435_761) & 0xff_ffff, // noise (1, _) => if (x + y) % 2 == 0 { 0xffff_ffff } else { 0xff00_0000 }, // 2 colours (2, _) => [0xff11_2233, 0xff44_5566, 0xff77_8899][(x / 3 + y) % 3], // 3 colours (3, _) => 0xff00_0000 | ((x / 10) as u32 * 0x30_1020), // runs