diff --git a/parser.c b/parser.c index e1d139d5d..c66dbae47 100644 --- a/parser.c +++ b/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