File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ use tiny_skia::Transform;
77
88use std:: cell:: RefCell ;
99use std:: collections:: hash_map;
10- use std:: fs;
1110use std:: sync:: Arc ;
11+ use std:: { fs, panic} ;
1212
1313#[ derive( Debug ) ]
1414pub struct Pipeline {
@@ -169,7 +169,20 @@ impl Cache {
169169 tiny_skia:: Transform :: default ( )
170170 } ;
171171
172- resvg:: render ( tree, transform, & mut image. as_mut ( ) ) ;
172+ // SVG rendering can panic on malformed or complex vectors.
173+ // We catch panics to prevent crashes and continue gracefully.
174+ let render_result =
175+ panic:: catch_unwind ( panic:: AssertUnwindSafe ( || {
176+ resvg:: render ( tree, transform, & mut image. as_mut ( ) ) ;
177+ } ) ) ;
178+
179+ if render_result. is_err ( ) {
180+ log:: warn!(
181+ "SVG rendering panicked for handle ID: {}" ,
182+ handle. id( )
183+ ) ;
184+ return None ;
185+ }
173186
174187 if let Some ( [ r, g, b, _] ) = key. color {
175188 // Apply color filter
You can’t perform that action at this time.
0 commit comments