[core] fix invalid read in Queue::write_texture (#7893)

This commit is contained in:
Lucas Abel 2025-07-16 18:49:03 +02:00 committed by GitHub
parent 1da2177547
commit 13d0cd4d58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -860,7 +860,6 @@ impl Queue {
wgt::BufferSize::new(stage_bytes_per_row as u64 * block_rows_in_copy as u64)
.unwrap();
let mut staging_buffer = StagingBuffer::new(&self.device, stage_size)?;
let copy_bytes_per_row = stage_bytes_per_row.min(bytes_per_row) as usize;
for layer in 0..size.depth_or_array_layers {
let rows_offset = layer * rows_per_image;
for row in rows_offset..rows_offset + height_in_blocks {
@ -871,7 +870,7 @@ impl Queue {
data,
src_offset as isize,
dst_offset as isize,
copy_bytes_per_row,
bytes_in_last_row as usize,
)
}
}

View File

@ -1076,6 +1076,13 @@ impl StagingBuffer {
size: usize,
) {
unsafe {
debug_assert!(
(src_offset + size as isize) as usize <= data.len(),
"src_offset + size must be in-bounds: src_offset = {}, size = {}, data.len() = {}",
src_offset,
size,
data.len()
);
core::ptr::copy_nonoverlapping(
data.as_ptr().offset(src_offset),
self.ptr.as_ptr().offset(dst_offset),