Fixing a memory leak of xmlEntityPtr in librsvg - Federico's Blog
Fixing a memory leak of xmlEntityPtr in librsvg Translations: es Friday 21/June/2024 - Tags: gnome, librsvg, refactoring, rust Since a few weeks ago, librsvg is now in oss-fuzz — Google's constantly-running fuzz-testing for OSS projects — and the crashes have started coming in. I'll have a lot m...
Hasnain says:
“Resources that are external to Rust really work best if they are wrapped at the lowest level, so that destructors can run automatically. Instead of freeing things by hand when you think it's right, let the compiler do it automatically when it knows it's right. In this case, wrapping xmlEntityPtr with a newtype and adding an impl Drop is all that is needed for the rest of the code to look like it's handling a normal, automatically-managed Rust object.”
Posted on 2024-06-24T04:20:10+0000