Commit 956534e0 authored by Nick Wellnhofer's avatar Nick Wellnhofer
Browse files

Check for custom free function in global destructor

Calling a custom deallocation function in the global destructor could
cause all kinds of unexpected problems. See for example

    https://github.com/sparklemotion/nokogiri/issues/2059

Only clean up if memory is managed with malloc/free.
parent 8e7c20a1
Pipeline #201704 passed with stage
in 3 minutes and 55 seconds
......@@ -14696,7 +14696,12 @@ xmlCleanupParser(void) {
static void
ATTRIBUTE_DESTRUCTOR
xmlDestructor(void) {
xmlCleanupParser();
/*
* Calling custom deallocation functions in a destructor can cause
* problems, for example with Nokogiri.
*/
if (xmlFree == free)
xmlCleanupParser();
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment