szn

Bug 465 — SGR 38;2/48;2 wraps out-of-range RGB with mod 256 instead of ignoring

465. Inconsistent out-of-range policy between indexed and RGB SGR

Severity: LOW Status: ❌ FALSE POSITIVE (intentional, tested behaviour) Files: src/screen.zig


Resolution

Re-evaluated against src/screen.zig:2137 (test "setSgr out-of-range colour params do not panic — bug #354"), which explicitly pins the wrap:

// RGB wraps mod 256: 300 % 256 == 44.
screen.setSgr(&[_]u32{ 38, 2, 300, 0, 0 }, &[_]bool{ false, false, false, false, false });
try testing.expectEqual(Colour.fromRgb(44, 0, 0), screen.cur_cell.fg);

The #354 fix deliberately chose % 256 for RGB (panic-free, deterministic) while ignoring out-of-range indexed colours. No legitimate program emits components above 255, so the only impact is a cosmetic shade difference on hostile input — no panic, no leak, no desync. Changing it would break the tested #354 contract for zero user-visible benefit. No code change made.