mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
graphics-server: bounds-check for negative coords
This prevents us from drawing pixels off the screen. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
8759f552f7
commit
e73fe08a3e
1 changed files with 3 additions and 0 deletions
|
|
@ -107,6 +107,9 @@ impl DrawTarget<BinaryColor> for XousDisplay {
|
|||
/// Draw a `Pixel` that has a color defined as `BinaryColor`.
|
||||
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||
let Pixel(coord, color) = pixel;
|
||||
if coord.x < 0 || coord.y < 0 {
|
||||
return Ok(())
|
||||
}
|
||||
if coord.x < FB_WIDTH_PIXELS as _ && coord.y < FB_LINES as _ {
|
||||
let framebuffer = self.fb.as_mut_ptr() as *mut u32;
|
||||
let offset = (coord.x / 32 + coord.y * FB_WIDTH_WORDS as i32) as usize;
|
||||
|
|
|
|||
Loading…
Reference in a new issue