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.
|
||||
// We catch panics to prevent crashes and continue gracefully.
|
||||
let render = panic::catch_unwind(panic::AssertUnwindSafe(|| {
|
||||
let render_result =
|
||||
panic::catch_unwind(panic::AssertUnwindSafe(|| {
|
||||
resvg::render(tree, transform, &mut image.as_mut());
|
||||
}));
|
||||
|
||||
if let Err(error) = render {
|
||||
log::warn!("SVG rendering for {handle:?} panicked: {error:?}");
|
||||
if render_result.is_err() {
|
||||
log::warn!(
|
||||
"SVG rendering panicked for handle ID: {}",
|
||||
handle.id()
|
||||
);
|
||||
return None;
|
||||
}
|
||||
|
||||
if let Some([r, g, b, _]) = key.color {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue