[libxml2] Check for custom free function in global destructor
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Check for custom free function in global destructor
- Date: Tue, 4 Aug 2020 17:51:15 +0000 (UTC)
commit 956534e02ef280795a187c16f6ac04e107f23c5d
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Tue Aug 4 19:27:13 2020 +0200
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.
parser.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]