[Libreoffice-commits] core.git: sax/source
dante (via logerrit)
logerrit at kemper.freedesktop.org
Sat Dec 19 15:09:59 UTC 2020
sax/source/fastparser/fastparser.cxx | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
New commits:
commit f460d8e8178cc6fad02347e2bab6580efe51c260
Author: dante <dante19031999 at gmail.com>
AuthorDate: Fri Dec 18 03:25:21 2020 +0100
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Dec 19 16:09:18 2020 +0100
Proposition for solution for memory error in 106804
https://gerrit.libreoffice.org/c/core/+/106804
This needs to be merged in the 7.1, it corrects a memory leak introduced in this same version.
Change-Id: Id3c3f86f88c32e631f0c414fbd7942aba2a91239
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107930
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 94d2651d4dff..f2a1ef3f2a92 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -227,6 +227,7 @@ public:
private:
std::vector<ReplacementPair> m_Replacements;
+ std::vector<xmlEntityPtr> m_TemporalEntities;
public:
// XFastParser
@@ -673,6 +674,8 @@ FastSaxParserImpl::~FastSaxParserImpl()
{
if( mxDocumentLocator.is() )
mxDocumentLocator->dispose();
+ for ( size_t i = 0; i < m_TemporalEntities.size(); ++i )
+ if (m_TemporalEntities[i] != nullptr) xmlFree(m_TemporalEntities[i]);
}
void FastSaxParserImpl::DefineNamespace( const OString& rPrefix, const OUString& namespaceURL )
@@ -1398,9 +1401,13 @@ xmlEntityPtr FastSaxParserImpl::callbackGetEntity( const xmlChar *name )
{
auto it = std::lower_bound(m_Replacements.begin(), m_Replacements.end(), dname);
if (it != m_Replacements.end() && it->name.compareToAscii(dname) == 0)
- return xmlNewEntity(
+ {
+ xmlEntityPtr entpt = xmlNewEntity(
nullptr, name, XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
BAD_CAST(OUStringToOString(it->replacement, RTL_TEXTENCODING_UTF8).getStr()));
+ m_TemporalEntities.push_back(entpt);
+ return entpt;
+ }
}
if( lname < 2 )
return xmlGetPredefinedEntity(name);
@@ -1415,21 +1422,23 @@ xmlEntityPtr FastSaxParserImpl::callbackGetEntity( const xmlChar *name )
if( cval == 0 )
return xmlGetPredefinedEntity(name);
OUString vname( &cval, 1 );
- return xmlNewEntity( nullptr,
- name,
- XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
- BAD_CAST(OUStringToOString(vname,RTL_TEXTENCODING_UTF8).getStr()));
+ xmlEntityPtr entpt
+ = xmlNewEntity(nullptr, name, XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
+ BAD_CAST(OUStringToOString(vname, RTL_TEXTENCODING_UTF8).getStr()));
+ m_TemporalEntities.push_back(entpt);
+ return entpt;
}
else
{
cval = static_cast<sal_uInt32>( strtoul( dname + 2, nullptr, 10 ) );
if( cval == 0 )
return xmlGetPredefinedEntity(name);
- OUString vname( &cval, 1 );
- return xmlNewEntity( nullptr,
- name,
- XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
- BAD_CAST(OUStringToOString(vname,RTL_TEXTENCODING_UTF8).getStr()));
+ OUString vname(&cval, 1);
+ xmlEntityPtr entpt
+ = xmlNewEntity(nullptr, name, XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
+ BAD_CAST(OUStringToOString(vname, RTL_TEXTENCODING_UTF8).getStr()));
+ m_TemporalEntities.push_back(entpt);
+ return entpt;
}
}
return xmlGetPredefinedEntity(name);
More information about the Libreoffice-commits
mailing list