szn

Bug 282 — processInput use-after-free when a prompt command kills the session

282. processInput use-after-free when a prompt command kills the session

File: src/server/server.zig:1084–1237 Severity: HIGH Status: ✅ FIXED — processInput re-resolves the active session/window/pane on every loop iteration and stops when nothing remains, so a prompt command that kills the session can’t leave stale dereferences. Regression test: kill-session prompt command with a trailing byte in the same packet.

session/window/pane are captured once at lines 1085–1087. At line 1157 a command dispatched from the prompt (dispatch.dispatchCommand) may call killAllSessions()/killSession()/killWindow(), which deinit the session’s arena (session.zig:64). The loop keeps dereferencing the stale pane/session at lines 1095 (pane.choose_mode.active, pane.screen.copy_mode), 1101 (pane.writeInput), and 1630–1636.

Trigger: User types kill-session default (or a keybinding fires kill-pane) and more bytes remain in the same stdin_data packet. Freed GPA memory is reused → crash/UB.