szn

Bug 269 — Potential Buffer Memory Leak in addSixelImage

269. Potential Buffer Memory Leak in addSixelImage

File: src/screen.zig:207–245 Severity: MEDIUM Status: ✅ FIXED — added errdefer self.allocator.free(dcs_bytes) at function entry and explicit free(dcs_bytes) on early return path for oversized images. Unit test added.

addSixelImage accepts ownership of dcs_bytes: []u8. If placeSixelImage fails (e.g. OutOfMemory during grid scroll-up), execution unwinds before dcs_bytes is stored in the sixel_images array.

Impact: Memory leak whenever sixel image placement fails due to allocation errors.