szn

Bug 426 — Robustness residuals cluster

426. Robustness residuals cluster: two unguarded history subtractions (#380 follow-up), OOM-path errdefer ordering, socket/TMP issues, and misc input/parse hardening

Severity: LOW Status: ✅ RESOLVED

| # | Site | Finding | |—|——|———| | a | render.zig:217,490 | raw history.items.len - history_start bypasses the guarded historyLen() accessor built for bug #293 (the #380 sweep fixed six sites; two remain, both in the render hot loop). | | b | cfg.zig:199-207 | errdefer free(flags.option) is scoped inside the if-block and inactive when the later directives.append fails; parseConfig has no errdefer result.deinit — mid-parse OOM leaks accumulated directives. | | c | grid.zig:872-936,167-170 | reflow OOM path leaves vis_list/padding lines unreachable (GPA build) and clone’s second errdefer re-frees items already appended into self.lines. | | d | server.zig:1706-1708,1822-1824,1978-1980 | yank/paste paths errdefer the generated name but leak the GPA selection data when pushOwned fails (OOM-only). | | e | socket_path.zig:22-31,52 | XDG/TMPDIR branches try bufPrintZ with no /tmp fallback (unlike HOME) — a long $TMPDIR breaks resolution entirely; the /tmp/szn-<uid>.sock fallback is first-binder-squat-prone in shared /tmp. | | f | key.zig:70 | kitty mod_param parsed as u8: masks > 255 (;256u) catch null silently drop modifiers. | | g | choose.zig:83-96,118-121 | item names written byte-per-cell (UTF-8 mojibake); Enter with zero items returns .cancelled but leaves active = true. | | h | main.zig:564-577,614-631 | cell-size reply digits overflow u32 (10+ digit reply panics in Debug); startup identify/resize use try writeAll before the socket is made O_NONBLOCK — a momentary EAGAIN aborts the client at startup. | | i | render.zig:83-92 (client use) | writeBytes maps EAGAIN to WriteFailed; enter/alt-screen + mouse/kitty push-pop are not paired, so a transiently-full stdout can drop one half of the bracket (unpaired ?1049). | | j | tty.zig:20-25 vs render.zig:561-565 | Attr→SGR tables duplicated, one with a count-only assert, values diverge (double-underline "21" vs "4:2") — an Attr field reorder silently misstyles one renderer. | | k | screen.zig:949-1021 | CSI 3J frees every sixel and sets force_clear but clears **no cells** (mode 3 falls into the no-op else). | | l | screen.zig:1374-1404 | resetHard (RIS) leaves pending_sixel (replays onto the reset screen), alt_grid/alt_cursor, and copy_mode. | | m | input.zig:202-204 | ground-state 0x08 decrements cursor.x directly, bypassing the wrap-aware backspace in Screen.writeChar (:667-675) — same byte behaves differently via parser vs writeStr. | | n | dispatch.zig:28-30 | commands longer than ~248 B log as “command: unknown”` (bufPrint NoSpaceLeft catch) — audit log lies instead of truncating. | | o | input.zig:588-589 | every captured sixel logs at info level with a raw 40-byte binary preview — hot-path spam. |

Fix: item-by-item hardening; none individually critical, together they are the residual surface.