szn

Bug 315 — cmdMoveWindow orphans window and leaks memory on insert OOM rollback failure

315. cmdMoveWindow orphans window and leaks memory on insert OOM rollback failure

File: src/cmd/cmd.zig:203-237 Severity: HIGH Status: ✅ FIXED

When cmdMoveWindow extracted a window via session.windows.orderedRemove(src_idx) and attempted insert(..., dst_idx), if insertion failed due to OOM, the rollback attempt session.windows.insert(arena_alloc, src_idx, w) catch {} used the same exhausted allocator and silently failed.

Root Cause

Rollback allocation relied on an exhausted arena allocator and swallowed failure, leaving the extracted window unreferenced in session.windows.

Fix

Added session.windows.ensureTotalCapacity(arena_alloc, session.windows.items.len) prior to orderedRemove in cmdMoveWindow so insertion into the array list cannot fail from allocation limits. On rollback failure, the window is now deinitialized and destroyed cleanly.