From 4f0d8b867e21d7deb29f1eedaf7f7217aef787c5 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Tue, 9 Jan 2024 14:50:30 +0100 Subject: [PATCH] Validate that a binding offset fits in the buffer --- wgpu-core/src/device/resource.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index be14008564..d597049709 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -1832,7 +1832,16 @@ impl Device { } (size.get(), end) } - None => (buffer.size - bb.offset, buffer.size), + None => { + if buffer.size < bb.offset { + return Err(Error::BindingRangeTooLarge { + buffer: bb.buffer_id, + range: bb.offset..bb.offset, + size: buffer.size, + }); + } + (buffer.size - bb.offset, buffer.size) + } }; if bind_size > range_limit as u64 {