mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
font/sprite: bounds checking for pixel writes on Pixman
This commit is contained in:
@ -409,6 +409,11 @@ const PixmanImpl = struct {
|
||||
|
||||
/// Draw and fill a single pixel
|
||||
pub fn pixel(self: *Canvas, x: u32, y: u32, color: Color) void {
|
||||
if (comptime std.debug.runtime_safety) {
|
||||
assert(x < self.image.getWidth());
|
||||
assert(y < self.image.getHeight());
|
||||
}
|
||||
|
||||
const boxes = &[_]pixman.Box32{
|
||||
.{
|
||||
.x1 = @intCast(x),
|
||||
@ -433,10 +438,13 @@ const PixmanImpl = struct {
|
||||
},
|
||||
};
|
||||
|
||||
if (comptime std.debug.runtime_safety) {
|
||||
assert(boxes[0].x1 >= 0);
|
||||
assert(boxes[0].y1 >= 0);
|
||||
assert(boxes[0].x2 <= @as(i32, @intCast(self.image.getWidth())));
|
||||
assert(boxes[0].y2 <= @as(i32, @intCast(self.image.getHeight())));
|
||||
}
|
||||
|
||||
self.image.fillBoxes(.src, color.pixmanColor(), boxes) catch {};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user