mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-26 00:37:43 +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:
5
parser.c
5
parser.c
@@ -14696,6 +14696,11 @@ xmlCleanupParser(void) {
|
|||||||
static void
|
static void
|
||||||
ATTRIBUTE_DESTRUCTOR
|
ATTRIBUTE_DESTRUCTOR
|
||||||
xmlDestructor(void) {
|
xmlDestructor(void) {
|
||||||
|
/*
|
||||||
|
* Calling custom deallocation functions in a destructor can cause
|
||||||
|
* problems, for example with Nokogiri.
|
||||||
|
*/
|
||||||
|
if (xmlFree == free)
|
||||||
xmlCleanupParser();
|
xmlCleanupParser();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user