1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

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.
This commit is contained in:
Nick Wellnhofer 2020-08-04 19:27:13 +02:00
parent 8e7c20a1af
commit 956534e02e

View File

@ -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