Base: Fixed segfault on destructing cached string (#20563)
* Base: Fixed segfault on destructing cached string Xerces default memory manager is deleted before destructing static local variable and segfault. --------- Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
This commit is contained in:
@@ -23,6 +23,11 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <xercesc/framework/MemoryManager.hpp>
|
||||
#include <xercesc/util/OutOfMemoryException.hpp>
|
||||
#endif
|
||||
|
||||
#include "Exception.h"
|
||||
#include "XMLTools.h"
|
||||
|
||||
@@ -128,3 +133,19 @@ void XMLTools::terminate()
|
||||
{
|
||||
transcoder.reset();
|
||||
}
|
||||
|
||||
void* XStrMemoryManager::allocate(XMLSize_t size)
|
||||
{
|
||||
auto ptr = ::operator new(static_cast<size_t>(size),
|
||||
static_cast<std::align_val_t>(alignof(XMLCh)),
|
||||
std::nothrow);
|
||||
if (ptr == nullptr && size != 0) {
|
||||
throw XERCES_CPP_NAMESPACE::OutOfMemoryException();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void XStrMemoryManager::deallocate(void* p)
|
||||
{
|
||||
::operator delete(p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user