szn

Bug 367 — merged_screen dangling optional on OOM resize path

367. One-line fix: null the optional after deinit

File: src/server/render.zig:166-171 Severity: MEDIUM Status: ✅ FIXED

Fix (applied)

ms_ptr.* = null inserted between deinit and re-init so a failed Screen.init cannot leave the optional pointing at the torn-down screen. No dedicated failure-injection test (would need a full DisplayClient harness); the ordering change is covered on the success path by the existing merged-screen render tests, which all pass.

Problem

if (ms_ptr.*) |*ms| { ms.deinit(); }   // not nulled
ms_ptr.* = try Screen.init(...);       // if this fails → dangling non-null

On init failure the optional still holds a destroyed Screen; the next frame takes the “already sized” branch and renders through freed grids.

Fix (proposed)

if (ms_ptr.*) |*ms| { ms.deinit(); ms_ptr.* = null; }

Add a failure-injection test if practical.