a73x

49903c96

Widen readbackOffscreen assert to usize

a73x   2026-04-17 16:38

Commit message
Widen readbackOffscreen assert to usize

Prevents silent u32 overflow on width*height*4 for large targets.
Not reachable at current 80x24 call sites, but matches the usize
semantics of the slice length it compares against.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

src/renderer.zig
Old New
@@ -1922,7 +1922,7 @@ pub const Context = struct {
1922 out_rgba: []u8, 1922 out_rgba: []u8,
1923 ) !void { 1923 ) !void {
1924 std.debug.assert(target.format == .b8g8r8a8_unorm); // swizzle below assumes BGRA8 1924 std.debug.assert(target.format == .b8g8r8a8_unorm); // swizzle below assumes BGRA8
1925 std.debug.assert(out_rgba.len == target.width * target.height * 4); 1925 std.debug.assert(out_rgba.len == @as(usize, target.width) * @as(usize, target.height) * 4);
1926 if (out_rgba.len < target.readback_size) return error.BufferTooSmall; 1926 if (out_rgba.len < target.readback_size) return error.BufferTooSmall;
1927 1927
1928 const mapped = try self.vkd.mapMemory( 1928 const mapped = try self.vkd.mapMemory(