szn

Bug 226 — Dangling pointer in status bar prompt rendering

226. Dangling pointer in status bar prompt rendering

File: src/server/render.zig:667–671 Severity: CRITICAL Status: ✅ FIXED

if (...) {
    var buf: [2]u8 = undefined;
    prompt = std.fmt.bufPrint(&buf, ...) catch "";
}

The prompt slice is assigned from a block that returns a slice of stack-allocated buf: [2]u8. Once the if block exits, buf goes out of scope, leaving prompt as a dangling pointer before being passed to writeBytes(prompt).

Impact: Undefined behavior, memory corruption, or garbled prompt output during status bar rendering.

Fix: Move var prompt_buf: [2]u8 = undefined; outside and before the if block.