From f7b650d55c6c4a546db236a0779f18fe4ee7d82f Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Fri, 10 Apr 2026 21:46:34 +0200 Subject: [PATCH] [wgpu-core] fix potential crash when device is not supplied to `validate_render_bundle_encoder_descriptor` (#9407) --- wgpu-core/src/command/bundle.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index bd886ec3c..e02307806 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -185,12 +185,11 @@ fn validate_render_bundle_encoder_descriptor( ) -> Result<(bool, bool), CreateRenderBundleError> { let mut have_attachment = false; - if let Some(device) = device { - check_color_attachment_count( - desc.color_formats.len(), - device.limits.max_color_attachments, - )?; - } + let max_color_attachments = device.map_or(hal::MAX_COLOR_ATTACHMENTS as u32, |device| { + assert!(device.limits.max_color_attachments <= hal::MAX_COLOR_ATTACHMENTS as u32); + device.limits.max_color_attachments + }); + check_color_attachment_count(desc.color_formats.len(), max_color_attachments)?; for &format in desc.color_formats.iter().flatten() { have_attachment = true;