Commit c7c526d6 authored by Kevin Puetz's avatar Kevin Puetz Committed by Nick Wellnhofer
Browse files

Fix memory leak when shared libxml.dll is unloaded

When a multiple modules (process/plugins) all link to libxml2.dll
they will in fact share a single loaded instance of it.
It is unsafe for any of them to call xmlCleanupParser,
as this would deinitialize the shared state and break others that might
still have ongoing use.

However, on windows atexit is per-module (rather process-wide), so if used
*within* libxml2 it is possible to register a clean up when all users
are done and libxml2.dll is about to actually unload.

This allows multiple plugins to link with and share libxml2 without
a premature cleanup if one is unloaded, while still cleaning up if *all*
such callers are themselves unloaded.
parent 453bdfb9
......@@ -14741,6 +14741,10 @@ xmlInitParser(void) {
if (xmlParserInitialized != 0)
#if defined(WIN32) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
if (xmlParserInitialized == 0) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment