From f2613f715b207efa5e0a4620113a27f89bbf0b4d Mon Sep 17 00:00:00 2001 From: n4n5 Date: Sun, 14 Dec 2025 14:40:42 -0700 Subject: [PATCH 1/5] handle unwrap --- crates/resvg/src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/resvg/src/main.rs b/crates/resvg/src/main.rs index 896d60cc0..ba282a2e9 100644 --- a/crates/resvg/src/main.rs +++ b/crates/resvg/src/main.rs @@ -703,10 +703,11 @@ fn render_svg(args: &Args, tree: &usvg::Tree) -> Result Result Date: Mon, 15 Dec 2025 18:10:19 -0700 Subject: [PATCH 2/5] fix comments --- crates/resvg/src/main.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/resvg/src/main.rs b/crates/resvg/src/main.rs index ba282a2e9..4e423b329 100644 --- a/crates/resvg/src/main.rs +++ b/crates/resvg/src/main.rs @@ -675,17 +675,16 @@ fn render_svg(args: &Args, tree: &usvg::Tree) -> Result return Err(format!("SVG doesn't have '{}' ID", id)), }; - let bbox = node - .abs_layer_bounding_box() - .ok_or_else(|| "node has zero size".to_string())?; + let bbox = node.abs_layer_bounding_box().ok_or("Node has zero size")?; let size = args .fit_to .fit_to_size(bbox.size().to_int_size()) - .ok_or_else(|| "target size is zero".to_string())?; + .ok_or("Target size is zero")?; - // Unwrap is safe, because `size` is already valid. - let mut pixmap = tiny_skia::Pixmap::new(size.width(), size.height()).unwrap(); + // Pixmap's width is limited by i32::MAX/4, we handle the creation error. + let mut pixmap = + tiny_skia::Pixmap::new(size.width(), size.height()).ok_or("Cannot create pixmap")?; if !args.export_area_page { if let Some(background) = args.background { @@ -705,7 +704,7 @@ fn render_svg(args: &Args, tree: &usvg::Tree) -> Result Result Date: Tue, 16 Dec 2025 02:11:13 +0100 Subject: [PATCH 3/5] Apply suggestion from @LaurenzV Co-authored-by: Laurenz Stampfl <47084093+LaurenzV@users.noreply.github.com> --- crates/resvg/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/resvg/src/main.rs b/crates/resvg/src/main.rs index 4e423b329..e69bd369a 100644 --- a/crates/resvg/src/main.rs +++ b/crates/resvg/src/main.rs @@ -706,7 +706,7 @@ fn render_svg(args: &Args, tree: &usvg::Tree) -> Result Date: Tue, 16 Dec 2025 02:11:24 +0100 Subject: [PATCH 4/5] Apply suggestion from @LaurenzV Co-authored-by: Laurenz Stampfl <47084093+LaurenzV@users.noreply.github.com> --- crates/resvg/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/resvg/src/main.rs b/crates/resvg/src/main.rs index e69bd369a..6f60201f6 100644 --- a/crates/resvg/src/main.rs +++ b/crates/resvg/src/main.rs @@ -732,7 +732,7 @@ fn render_svg(args: &Args, tree: &usvg::Tree) -> Result Date: Mon, 15 Dec 2025 18:12:09 -0700 Subject: [PATCH 5/5] lowercase --- crates/resvg/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/resvg/src/main.rs b/crates/resvg/src/main.rs index 6f60201f6..830eb8d4f 100644 --- a/crates/resvg/src/main.rs +++ b/crates/resvg/src/main.rs @@ -675,16 +675,16 @@ fn render_svg(args: &Args, tree: &usvg::Tree) -> Result return Err(format!("SVG doesn't have '{}' ID", id)), }; - let bbox = node.abs_layer_bounding_box().ok_or("Node has zero size")?; + let bbox = node.abs_layer_bounding_box().ok_or("node has zero size")?; let size = args .fit_to .fit_to_size(bbox.size().to_int_size()) - .ok_or("Target size is zero")?; + .ok_or("target size is zero")?; // Pixmap's width is limited by i32::MAX/4, we handle the creation error. let mut pixmap = - tiny_skia::Pixmap::new(size.width(), size.height()).ok_or("Cannot create pixmap")?; + tiny_skia::Pixmap::new(size.width(), size.height()).ok_or("cannot create pixmap")?; if !args.export_area_page { if let Some(background) = args.background {