rockorager / libvaxis

a modern tui library written in zig
https://rockorager.github.io/libvaxis/
MIT License
463 stars 32 forks source link

panic: index out of bounds in Window.fill if windows is partially off screen #65

Closed neurocyte closed 3 months ago

neurocyte commented 3 months ago

Resizing Flow to a very small size with the open recent file list (Ctrl-e) open triggers a crash in Window.fill()

thread 119071 panic: index out of bounds: index 153, len 136
/home/cjv/.cache/zig/p/122029efd74ef26d203b287a6135a8d47e48401fe982fa4f629e0a46e0949160e91b/src/Window.zig:222:32: 0x3a1828b in fill (flow)
        @memset(self.screen.buf[start..end], cell);
                               ^
/home/cjv/src/flow/src/renderer/vaxis/Plane.zig:70:21: 0x397e76d in erase (flow)
    self.window.fill(.{ .style = self.style_base });
                    ^
/home/cjv/src/flow/src/tui/mode/overlay/open_recent.zig:95:23: 0x394817a in on_render_menu (flow)
    button.plane.erase();
                      ^

I suspect there should be a bounds check for the end value calculated on line 221.