mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-19 14:00:29 +00:00
terminal: fix uninitialized memory in Cell init
This commit is contained in:
@@ -2043,10 +2043,13 @@ pub const Cell = packed struct(u64) {
|
||||
|
||||
/// Helper to make a cell that just has a codepoint.
|
||||
pub fn init(cp: u21) Cell {
|
||||
return .{
|
||||
.content_tag = .codepoint,
|
||||
.content = .{ .codepoint = cp },
|
||||
};
|
||||
// We have to use this bitCast here to ensure that our memory is
|
||||
// zeroed. Otherwise, the content below will leave some uninitialized
|
||||
// memory in the packed union. Valgrind verifies this.
|
||||
var cell: Cell = @bitCast(@as(u64, 0));
|
||||
cell.content_tag = .codepoint;
|
||||
cell.content = .{ .codepoint = cp };
|
||||
return cell;
|
||||
}
|
||||
|
||||
pub fn isZero(self: Cell) bool {
|
||||
|
||||
Reference in New Issue
Block a user