Skip to content

resvg_render() (C wrapper function) does not crash on incorrect input#926

Open
geometer wants to merge 3 commits intolinebender:mainfrom
FBReader:main
Open

resvg_render() (C wrapper function) does not crash on incorrect input#926
geometer wants to merge 3 commits intolinebender:mainfrom
FBReader:main

Conversation

@geometer
Copy link
Copy Markdown

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).

@LaurenzV
Copy link
Copy Markdown
Collaborator

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?

@RazrFalcon
Copy link
Copy Markdown
Collaborator

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.

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.

3 participants