1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-28 23:14:57 +03:00

Reset last error in xmlCleanupGlobals

Before, we tried to reset the last error in xmlCleanupParser. But if
xmlCleanupParser wasn't called from the main thread, this would reset
the thread-local error object. xmlCleanupGlobals has access to the
error object of the main thread and can reset it reliably.
This commit is contained in:
Nick Wellnhofer
2022-03-01 15:14:00 +01:00
parent ebc5009793
commit 89d9ef3ee8
2 changed files with 16 additions and 15 deletions

View File

@@ -50,20 +50,6 @@ void xmlInitGlobals(void)
xmlThrDefMutex = xmlNewMutex();
}
/**
* xmlCleanupGlobals:
*
* Additional cleanup for multi-threading
*/
void xmlCleanupGlobals(void)
{
if (xmlThrDefMutex != NULL) {
xmlFreeMutex(xmlThrDefMutex);
xmlThrDefMutex = NULL;
}
__xmlGlobalInitMutexDestroy();
}
/************************************************************************
* *
* All the user accessible global variables of the library *
@@ -1122,3 +1108,19 @@ __xmlOutputBufferCreateFilenameValue(void) {
return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
}
/**
* xmlCleanupGlobals:
*
* Additional cleanup for multi-threading
*/
void xmlCleanupGlobals(void)
{
xmlResetError(&xmlLastError);
if (xmlThrDefMutex != NULL) {
xmlFreeMutex(xmlThrDefMutex);
xmlThrDefMutex = NULL;
}
__xmlGlobalInitMutexDestroy();
}

View File

@@ -14753,7 +14753,6 @@ xmlCleanupParser(void) {
xmlSchemaCleanupTypes();
xmlRelaxNGCleanupTypes();
#endif
xmlResetLastError();
xmlCleanupGlobals();
xmlCleanupThreads(); /* must be last if called not from the main thread */
xmlCleanupMemory();