Skip to content

Specific SVG input file causing panic #1007

Closed

Description

@galister

Unexpected SVG input can cause the program to panic due to this assert:

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:

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());
}

Activity

  1. galister commented on Jan 12, 2026

    @galister
    Author

    Image

    here's the svg file separately, though I'm not sure if github alters it in any way

  2. added a commit that references this issue on Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions