Skip to content

Commit 42d9938

Browse files
committed
Check for divide by zero in svg scaling code
1 parent be1c78f commit 42d9938

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/widglets/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ pub fn svg_path_to_handle(path: PathBuf) -> Result<iced::widget::image::Handle,
3434
.ok_or("Can create pixmap")?;
3535

3636
let svg_size = tree.size();
37+
if svg_size.width() == 0.0 || svg_size.height() == 0.0 {
38+
return Err(String::from("Svg size or width was zero! Cannot scale"));
39+
}
40+
3741
let transform = resvg::tiny_skia::Transform::from_scale(
3842
SVG_WIDTH as f32 / svg_size.width(),
3943
SVG_HEIGHT as f32 / svg_size.height(),

0 commit comments

Comments
 (0)