From c8f637fc16099c70836574425a6df20a3e2fa801 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 17 Mar 2023 19:35:57 +0100 Subject: Fix panic rendering an out of bounds clip in `iced_tiny_skia` --- tiny_skia/src/backend.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tiny_skia/src') diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs index ba063f4e..271d026f 100644 --- a/tiny_skia/src/backend.rs +++ b/tiny_skia/src/backend.rs @@ -267,6 +267,14 @@ impl Backend { Primitive::Clip { bounds, content } => { let bounds = (*bounds + translation) * scale_factor; + if bounds.x + bounds.width <= 0.0 + || bounds.y + bounds.height <= 0.0 + || bounds.x as u32 >= pixels.width() + || bounds.y as u32 >= pixels.height() + { + return; + } + adjust_clip_mask(clip_mask, pixels, bounds); self.draw_primitive( -- cgit