szn

Bug 499 — InputParser.deinit allocator mismatch footgun

499. Parameter invites freeing into the wrong allocator

Severity: LOW (latent heap corruption via API misuse) Status: 🟢 FIXED Files: src/input.zig:91-94

Problem

pub fn deinit(self: *InputParser, allocator: std.mem.Allocator) void {
    self.dcs_buf.deinit(allocator);
    self.osc_buf.deinit(allocator);
}

All 13 allocation sites for these buffers use self.screen.allocator, but deinit accepts an arbitrary allocator parameter. Passing anything else (easy to do — the signature suggests the caller chooses) frees the buffers into the wrong allocator → heap corruption or crash. Tests happen to pass testing.allocator consistently, which masks the footgun.

Proposed Fix

Drop the parameter and free with self.screen.allocator internally — the parser already owns a reference to the allocating context, so the parameter serves no purpose except to invite misuse.

Resolution