Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bounds check to Buffer slice method #6432

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
avoid unwrap / double option check by using map_or
  • Loading branch information
Wumpf authored Oct 22, 2024
commit 8d700dba1bfe05ffb92d3206266acf967e4127f6
2 changes: 1 addition & 1 deletion wgpu/src/api/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ fn check_buffer_bounds(
if let Some(size) = size {
// Detect integer overflow.
let end = offset.checked_add(size.get());
if end.is_none() || end.unwrap() > buffer_size {
if end.map_or(true, |end| end > buffer_size) {
panic!(
"slice offset {} size {} is out of range for buffer of size {}",
offset, size, buffer_size
Expand Down