From 6299c62d52a1d031f3760412f306f9e564a0abc6 Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:38:22 -0600 Subject: [PATCH] Fix panic in SVG rendering (cherry-pick #11196) (#11198) Cherry-picked Fix panic in SVG rendering (#11196) Release Notes: - Fixed a panic in SVG rendering Co-authored-by: Conrad Irwin --- crates/gpui/src/svg_renderer.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/svg_renderer.rs b/crates/gpui/src/svg_renderer.rs index 0d45612cbdc9cdf518fd69c16c3ae8465ad3b569..54f52a55a834175dc8b939e9884530bade8aaa61 100644 --- a/crates/gpui/src/svg_renderer.rs +++ b/crates/gpui/src/svg_renderer.rs @@ -55,11 +55,12 @@ impl SvgRenderer { }; // Render the SVG to a pixmap with the specified width and height. - let mut pixmap = - resvg::tiny_skia::Pixmap::new(size.width.into(), size.height.into()).unwrap(); + let mut pixmap = resvg::tiny_skia::Pixmap::new(size.width.into(), size.height.into()) + .ok_or(usvg::Error::InvalidSize)?; let transform = tree.view_box().to_transform( - resvg::tiny_skia::Size::from_wh(size.width.0 as f32, size.height.0 as f32).unwrap(), + resvg::tiny_skia::Size::from_wh(size.width.0 as f32, size.height.0 as f32) + .ok_or(usvg::Error::InvalidSize)?, ); resvg::render(&tree, transform, &mut pixmap.as_mut());