Skip to content

Conversation

@hammerlink
Copy link

When rendering certain SVGs, resvg::render can panic because resvg uses several assert! calls internally. This caused application crashes in Cosmic Desktop: pop-os/cosmic-epoch#2452

This patch wraps the render call in std::panic::catch_unwind. If resvg panics, the panic is caught and None is returned instead of crashing the app.

Example problematic SVG:

<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">                                                    
  <defs>                                                                                                             
    <filter id="specular" width="50" height="50">                                              
      <feSpecularLighting result="specular" lighting-color="white"                                                   
                          x="10" y="10" width="5" height="5">                                                        
        <fePointLight x="50" y="50" z="200"/>                                                                        
      </feSpecularLighting>                                                                                          
    </filter>                                                                                                        
  </defs>                                                                                                            
  <rect width="100" height="100" fill="blue" filter="url(#specular)"/>                                               
</svg>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant