From 485a4d6d0f763019c3734f8015533ca18650c307 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Thu, 13 Jul 2023 16:00:45 +0200 Subject: [PATCH] Validate that BufferDesctor::usage is not zero. --- Cargo.lock | 2 +- wgpu-core/src/device/global.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index aaa0ba425a6..44dfb69f2a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1465,7 +1465,7 @@ name = "metal" version = "0.25.0" source = "git+https://github.com/gfx-rs/metal-rs.git?rev=a6a0446#a6a04463db388e8fd3e99095ab4fbb87cbe9d69c" dependencies = [ - "bitflags 2.3.1", + "bitflags 2.3.2", "block", "core-graphics-types", "foreign-types 0.5.0", diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index 77a4e4275c7..ff21ca08550 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -145,6 +145,12 @@ impl Global { Ok(device) => device, Err(_) => break DeviceError::Invalid.into(), }; + + if desc.usage.is_empty() { + // Per spec, `usage` must not be zero. + break resource::CreateBufferError::InvalidUsage(desc.usage); + } + #[cfg(feature = "trace")] if let Some(ref trace) = device.trace { let mut desc = desc.clone();