fix(wgpu): bounds check for images

This commit is contained in:
Ashley Wulber 2026-03-19 18:23:00 -04:00 committed by Ashley Wulber
parent 2d41248288
commit a3a434ac92

View file

@ -346,6 +346,24 @@ impl Atlas {
let pad_h = padding.height as usize;
let stride = PIXEL * w;
// bounds check for source pixels to fragment
if pixels.len() < offset + PIXEL * image_width as usize * h {
return;
}
// bounds check for pad_w low / high to fragment
if pad_w > 0
&& (offset + stride < PIXEL
|| offset
+ image_width as usize
* PIXEL
* (h.checked_sub(1).unwrap_or(0))
+ PIXEL
> pixels.len())
{
return;
}
// Copy image rows
for row in 0..h {
let src = offset + row * PIXEL * image_width as usize;