szn

Bug 459 — Grid.initWithLimit leaks lines buffer when resize fails

459. Missing errdefer between ensureTotalCapacity and fallible resize

Severity: LOW Status: ✅ FIXED Files: src/grid.zig


Root Cause Analysis

In src/grid.zig:105-106:

try grid.lines.ensureTotalCapacity(allocator, height);
try grid.resize(height);

resize allocates each line’s cells; on OOM the lines array is never deinited. Contrast clone:217 which has errdefer copy.deinit().

Proposed Fix

Add errdefer grid.lines.deinit(allocator); (and deinit any partially-created lines consistent with resize semantics) before try grid.resize.