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
}
spawn() fails before line 149 (or deinit is reached on a Pty that never spawned), deinit operates on an undefined allocator → undefined behavior / crash.deinit is not idempotent: a double deinit (e.g. via both the owning struct’s cleanup and an explicit call) frees with an allocator that may already be torn down, or frees the same resources twice.input_buf growth is also unbounded (no cap), compounding the fragility of the spawn/deinit lifecycle.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.