Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions wgpu/src/image/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading