mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +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:
7
parser.c
7
parser.c
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user