fix: integer overflow in scrollbar_v

This commit is contained in:
CJ van den Berg 2025-12-17 19:49:09 +01:00
parent 8dbc5765d9
commit 4f60e906d7
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -196,14 +196,14 @@ const eighths_c: u32 = eighths_b.len;
fn smooth_bar_at(plane: *Plane, pos_: u32, size_: u32) !void {
const height: u32 = plane.dim_y();
var size = @max(size_, 8);
const pos = @min(height * eighths_c - size, pos_);
const pos = @min(height * eighths_c -| size, pos_);
var pos_y: c_int = @intCast(@divFloor(pos, eighths_c));
const blk = @mod(pos, eighths_c);
const b = eighths_b[blk];
plane.erase();
plane.cursor_move_yx(pos_y, 0) catch return;
_ = try plane.putstr(@ptrCast(b));
size -= eighths_c - blk;
size -= eighths_c -| blk;
while (size >= 8) {
pos_y += 1;
size -= 8;