Avoid overflows for extreme scissor coordinates (#7459)

This commit is contained in:
Josh Groves authored and GitHub committed 2025-04-01 09:47:39 -04:00
1 parent a9279de793
commit ab38e8e430
1 file changed
+3 -1
+3 -1
View File
@@ -2408,7 +2408,9 @@ fn set_push_constant(
fn set_scissor(state: &mut State, rect: Rect<u32>) -> Result<(), RenderPassErrorInner> {
api_log!("RenderPass::set_scissor_rect {rect:?}");
if rect.x + rect.w > state.info.extent.width || rect.y + rect.h > state.info.extent.height {
if rect.x.saturating_add(rect.w) > state.info.extent.width
|| rect.y.saturating_add(rect.h) > state.info.extent.height
{
return Err(RenderCommandError::InvalidScissorRect(rect, state.info.extent).into());
}
let r = hal::Rect {