resvg_render() (C wrapper function) does not crash on incorrect input
Using the library in our C++ project via C wrappers, we found that the app crashes if SVG data are incorrect. E.g, contain extra chars after closing the root <svg> tag. The patch fixes that issue by catching a panic instead of throwing it into C++ code (where catching is impossible).
I think the right fix for this is to fix the crash in the Rust version instead? What file are you having problems with, and what is the backtrace?
Catching panics is probably a good idea, but you are checking for tree.is_null() twice. That's not needed.
Also, the code/API is expected to fail/abort on invalid arguments, so that's should stay as before.
Basically, only std::panic::catch_unwind is needed here.
But if we're adding std::panic::catch_unwind - we have to add it to all function that can panic, not just render one.
And yes, we should also fix the cause of the crash, not just handling of it.