mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
[core] fix invalid read in Queue::write_texture (#7893)
This commit is contained in:
1 parent
1da2177547
commit
13d0cd4d58
2 files changed
+8
-2
No files matched your search
@@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in new issue
Block a user