szn

Bug 283 — Dangling mouse_autoscroll_pane / mouse_press_pane after pane destruction

283. Dangling mouse_autoscroll_pane / mouse_press_pane after pane destruction

File: src/server/server.zig:154–156 Severity: HIGH Status: ✅ FIXED — destroyPane calls clearPaneMouseRefs(pane) before the pane is freed, and killSession/killAllSessions call clearPaneMouseRefsBulk(), which nulls mouse_press_pane, mouse_autoscroll_pane, and mouse_autoscroll_dir. This closes the UAF for both a single-pane kill (during a drag/autoscroll) and a whole-session kill mid-drag/autoscroll, without needing per-dereference guards.

mouse_press_pane: ?*Pane = null,
mouse_autoscroll_pane: ?*Pane = null,

Neither destroyPane (631–679), killSession (2503–2518), nor killAllSessions (2520–2533) clears these cached *Pane pointers. tickAutoscroll (413–431) dereferences pane.screen.copy_mode at the top of every run(); the drag/release handlers dereference mouse_press_pane at 1556/1604. If the pane exits (→ destroyPane) or its session is killed mid-drag/autoscroll, this is a UAF on freed arena memory.