Validate bind group buffer ranges
* Validate bind group buffer range
The bound buffer range must fit in the the buffer size.
@@ -1152,7 +1152,17 @@ pub fn device_create_bind_group(
.buffers
.use_extend(&*buffer_guard, bb.buffer, (), usage)
.unwrap();
- let range = Some(bb.offset) .. Some(bb.offset + bb.size);
+
+ let start = bb.offset;
+ let end = bb.offset + bb.size;
+ assert!(
+ end <= buffer.size,
+ "Bound buffer range {:?} does not fit in buffer size {}",
+ start .. end,
+ buffer.size
+ );
+
+ let range = Some(start) .. Some(end);
hal::pso::Descriptor::Buffer(&buffer.raw, range)
}
binding_model::BindingResource::Sampler(id) => {
