Skip to content

Commit

Permalink
[agx - Rust] A couple more basic checks to avoid underflowing a Layer…
Browse files Browse the repository at this point in the history
…Slice
  • Loading branch information
codyd51 committed Feb 7, 2024
1 parent 83a83d4 commit 9c09f79
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rust_programs/agx_definitions/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,20 @@ impl LikeLayerSlice for LayerSlice {
let mut fb = self.parent_framebuffer.borrow_mut();
let slice_origin_offset = self.frame.origin * bpp_multiple;

if self.frame.origin.x < 0 || self.frame.origin.y < 0 {
return;
}

let (src_base, src_slice_row_size, src_parent_framebuf_row_size) =
source_layer.get_buf_ptr_and_row_size();

for y in 0..self.frame().height() {
// Blit an entire row at once
let point_offset = slice_origin_offset + (Point::new(0, y) * bpp_multiple);
if point_offset.x < 0 || point_offset.y < 0 {
//println!("skipping neg row {point_offset}");
continue;
}
let off = (point_offset.y + point_offset.x) as usize;
let dst_row_slice = &mut fb[off..off + ((self.frame.width() * bpp) as usize)];
let src_row_slice = unsafe {
Expand Down

0 comments on commit 9c09f79

Please sign in to comment.