fix(container/layout): integer overflows by casting to usize
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m5s

This commit is contained in:
2025-02-28 15:55:10 +01:00
parent 3b6848f845
commit c28fcd26c1

View File

@@ -346,8 +346,8 @@ pub const Layout = packed struct {
for (0..children.len - 1) |idx| {
const child = children[idx];
const anchor = switch (this.direction) {
.horizontal => ((child.size.anchor.row -| size.anchor.row) * size.cols) + child.size.anchor.col + child.size.cols + gap -| size.anchor.col,
.vertical => ((child.size.anchor.row + child.size.rows + gap -| size.anchor.row) * size.cols) + child.size.anchor.col -| size.anchor.col,
.horizontal => ((@as(usize, child.size.anchor.row) -| @as(usize, size.anchor.row)) * @as(usize, size.cols)) + @as(usize, child.size.anchor.col) + @as(usize, child.size.cols) + gap -| @as(usize, size.anchor.col),
.vertical => ((@as(usize, child.size.anchor.row) + @as(usize, child.size.rows) + gap -| @as(usize, size.anchor.row)) * @as(usize, size.cols)) + @as(usize, child.size.anchor.col) -| @as(usize, size.anchor.col),
};
switch (this.direction) {