summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-12-20 14:34:56 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-12-20 19:26:18 +0100
commit813118bfbb453f812be9e1a30f84908b4e0bfb51 (patch)
tree7b032fc73b76a148ba98d85625596717e6f59d7d /xmloff
parente5f4aff517a674d12dd125601cc508feef854c15 (diff)
add checks to optional fields in SvXMLImportContext
so when I convert ImportContext to FastParser APIs I don't accidentally rely on data that is not there Change-Id: If4700c7902e11f98a57542943f6a198822689df8 Reviewed-on: https://gerrit.libreoffice.org/85622 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmlictxt.cxx3
-rw-r--r--xmloff/source/core/xmlimp.cxx4
2 files changed, 5 insertions, 2 deletions
diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx
index 092b1845c18c..b05a76b39969 100644
--- a/xmloff/source/core/xmlictxt.cxx
+++ b/xmloff/source/core/xmlictxt.cxx
@@ -32,13 +32,16 @@ SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp, sal_uInt16 nPrfx,
, mrImport(rImp)
, mnPrefix(nPrfx)
, maLocalName(rLName)
+ , mbPrefixAndLocalNameFilledIn(true)
{
+ assert(!rLName.isEmpty());
}
SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp )
: m_nRefCount(0)
, mrImport(rImp)
, mnPrefix(0)
+ , mbPrefixAndLocalNameFilledIn(false)
{
}
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 9c1f806a999c..578bef43a82c 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -729,7 +729,7 @@ void SAL_CALL SvXMLImport::startElement( const OUString& rName,
if(!maContexts.empty())
{
xContext = maContexts.top()->CreateChildContext(nPrefix, aLocalName, xAttrList);
- SAL_WARN_IF( !xContext.is() || (xContext->GetPrefix() != nPrefix), "xmloff.core",
+ SAL_WARN_IF( xContext.is() && xContext->IsPrefixFilledIn() && (xContext->GetPrefix() != nPrefix), "xmloff.core",
"SvXMLImport::startElement: created context has wrong prefix" );
}
else
@@ -782,7 +782,7 @@ rName
#ifdef DBG_UTIL
// Non product only: check if endElement call matches startELement call.
- if (!xContext->GetLocalName().isEmpty()) // prefix+localname are only valid in the non-FastParser case
+ if (xContext->IsPrefixFilledIn()) // prefix+localname are only valid in the non-FastParser case
{
OUString aLocalName;
sal_uInt16 nPrefix =