Skip to content

Commit ab38e8e

Browse files
authored
Avoid overflows for extreme scissor coordinates (gfx-rs#7459)
1 parent a9279de commit ab38e8e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

wgpu-core/src/command/render.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2408,7 +2408,9 @@ fn set_push_constant(
24082408
fn set_scissor(state: &mut State, rect: Rect<u32>) -> Result<(), RenderPassErrorInner> {
24092409
api_log!("RenderPass::set_scissor_rect {rect:?}");
24102410

2411-
if rect.x + rect.w > state.info.extent.width || rect.y + rect.h > state.info.extent.height {
2411+
if rect.x.saturating_add(rect.w) > state.info.extent.width
2412+
|| rect.y.saturating_add(rect.h) > state.info.extent.height
2413+
{
24122414
return Err(RenderCommandError::InvalidScissorRect(rect, state.info.extent).into());
24132415
}
24142416
let r = hal::Rect {

0 commit comments

Comments
 (0)