Skip to content

Commit

Permalink
Validate the range in map_async.
Browse files Browse the repository at this point in the history
  • Loading branch information
nical committed Jul 13, 2022
1 parent db24c06 commit 26f89e5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5428,6 +5428,16 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
return Err((op, e.into()));
}

if range.end > buffer.size {
return Err((
op,
BufferAccessError::OutOfBoundsOverrun {
index: range.start,
max: buffer.size,
},
));
}

buffer.map_state = match buffer.map_state {
resource::BufferMapState::Init { .. } | resource::BufferMapState::Active { .. } => {
return Err((op, BufferAccessError::AlreadyMapped));
Expand Down

0 comments on commit 26f89e5

Please sign in to comment.