szn

Bug 439 — Pty.allocator is ‘undefined’ until spawn(); deinit is non-idempotent

439. Pty.allocator is ‘undefined’ until spawn(); deinit is non-idempotent

Severity: LOW Status: Fixed

Pty.allocator starts as undefined and is only set inside spawn():

// src/server/pty.zig:122
allocator: std.mem.Allocator = undefined,
// ...
// src/server/pty.zig:149 (inside spawn)
self.allocator = alloc; // set only on the success path of spawn

deinit then uses self.allocator directly:

// src/server/pty.zig (deinit)
fn deinit(self: *Pty) void {
    // uses self.allocator to free resources
}

Problem & Impact

Proposed Fix

Initialize allocator to a known sentinel or require it as a constructor parameter; guard deinit with a deinited/spawned flag (or a ?Allocator) so it is a no-op when not spawned and idempotent afterwards. Consider bounding input_buf.