mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-06 07:38:21 +00:00
terminal/formatter: safely cast discarding.count to usize
The Discarding writer count field is u64, but appendNTimes expects usize which is u32 on 32-bit targets like arm-linux-androideabi. Use std.math.cast instead of @intCast to safely handle the conversion, returning WriteFailed on overflow rather than risking undefined behavior.
This commit is contained in:
@@ -293,7 +293,7 @@ pub const TerminalFormatter = struct {
|
||||
m.map.appendNTimes(
|
||||
m.alloc,
|
||||
self.terminal.screens.active.pages.getTopLeft(.screen),
|
||||
discarding.count,
|
||||
std.math.cast(usize, discarding.count) orelse return error.WriteFailed,
|
||||
) catch return error.WriteFailed;
|
||||
}
|
||||
}
|
||||
@@ -331,7 +331,7 @@ pub const TerminalFormatter = struct {
|
||||
m.map.appendNTimes(
|
||||
m.alloc,
|
||||
self.terminal.screens.active.pages.getTopLeft(.screen),
|
||||
discarding.count,
|
||||
std.math.cast(usize, discarding.count) orelse return error.WriteFailed,
|
||||
) catch return error.WriteFailed;
|
||||
}
|
||||
}
|
||||
@@ -415,7 +415,7 @@ pub const TerminalFormatter = struct {
|
||||
.y = last.y,
|
||||
};
|
||||
} else self.terminal.screens.active.pages.getTopLeft(.screen),
|
||||
discarding.count,
|
||||
std.math.cast(usize, discarding.count) orelse return error.WriteFailed,
|
||||
) catch return error.WriteFailed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user