-
Notifications
You must be signed in to change notification settings - Fork 289
Open
Description
Unexpected SVG input can cause the program to panic due to this assert:
resvg/crates/resvg/src/filter/lighting.rs
Line 140 in b8e58f5
| assert!(src.width == dest.width && src.height == dest.height); |
I believe this is a bug as a library should not panic depending on user-dependent input data.
Steps to reproduce:
- Install https://flathub.org/en/apps/io.github.davidoc26.wallpaper_selector
- Feed its icon into resvg
Code to reproduce panic (just cargo add resvg + cargo run)
fn main() {
let width = 96;
let height = 96;
let file_path = "/var/lib/flatpak/exports/share/icons/hicolor/scalable/apps/io.github.davidoc26.wallpaper_selector.svg";
let options = resvg::usvg::Options {
style_sheet: Some("svg { color: white }".into()),
..Default::default()
};
let data = std::fs::read(file_path).unwrap();
let tree = resvg::usvg::Tree::from_data(data.as_slice(), &options).unwrap();
let svg_size = tree.size();
let scale_x = (width as f32) / svg_size.width();
let scale_y = (height as f32) / svg_size.height();
let mut pixmap = resvg::tiny_skia::Pixmap::new(width as _, height as _).unwrap();
let transform = resvg::usvg::Transform::from_scale(scale_x, scale_y);
resvg::render(&tree, transform, &mut pixmap.as_mut());
}Its-Just-Nans
Metadata
Metadata
Assignees
Labels
No labels