fix: prevent crashes from SVG rendering
This commit is contained in:
parent
484aa0a532
commit
9b636e281b
1 changed files with 10 additions and 5 deletions
|
|
@ -175,12 +175,17 @@ impl Cache {
|
||||||
|
|
||||||
// SVG rendering can panic on malformed or complex vectors.
|
// SVG rendering can panic on malformed or complex vectors.
|
||||||
// We catch panics to prevent crashes and continue gracefully.
|
// We catch panics to prevent crashes and continue gracefully.
|
||||||
let render = panic::catch_unwind(panic::AssertUnwindSafe(|| {
|
let render_result =
|
||||||
resvg::render(tree, transform, &mut image.as_mut());
|
panic::catch_unwind(panic::AssertUnwindSafe(|| {
|
||||||
}));
|
resvg::render(tree, transform, &mut image.as_mut());
|
||||||
|
}));
|
||||||
|
|
||||||
if let Err(error) = render {
|
if render_result.is_err() {
|
||||||
log::warn!("SVG rendering for {handle:?} panicked: {error:?}");
|
log::warn!(
|
||||||
|
"SVG rendering panicked for handle ID: {}",
|
||||||
|
handle.id()
|
||||||
|
);
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some([r, g, b, _]) = key.color {
|
if let Some([r, g, b, _]) = key.color {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue