[Libreoffice-commits] core.git: xmloff/source
Caolán McNamara
caolanm at redhat.com
Sat Sep 16 19:34:46 UTC 2017
xmloff/source/core/xmlimp.cxx | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
New commits:
commit 6c87ecfaafab362d2d95dbcd976ffb5ea957097e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Sep 16 17:51:17 2017 +0100
valgrind: leak on fdo72541-1.fodt
by 0x43CEBF6E: cppu::OWeakObject::operator new(unsigned long) (weak.hxx:85)
by 0x449AD12D: SwXMLImport::CreateBodyContentContext(rtl::OUString const&) (xmltext.cxx:77)
by 0x449790B1: SwXMLBodyContext_Impl::CreateChildContext(unsigned short, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> const&) (xmlimp.cxx:165)
by 0x1451756D: SvXMLImport::startElement(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList> const&) (xmlimp.cxx:684)
by 0x14511961: SvXMLImportContext::startUnknownElement(rtl::OUString const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) (xmlictxt.cxx:124)
by 0x14511306: SvXMLImportContext::startFastElement(int, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) (xmlictxt.cxx:74)
by 0x145183A0: SvXMLImport::startFastElement(int, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) (xmlimp.cxx:834)
by 0x463D934A: (anonymous namespace)::Entity::startElement((anonymous namespace)::Event*) (fastparser.cxx:456)
by 0x463DD799: sax_fastparser::FastSaxParserImpl::callbackStartElement(unsigned char const*, unsigned char const*, unsigned char const*, int, unsigned char const**, int, unsigned char const**) (fastparser.cxx:1205)
Change-Id: I667eb9c7205f7e959b8b925d057b686ff74ef4b7
Reviewed-on: https://gerrit.libreoffice.org/42358
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index d58cb4216139..3ea020a86e72 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -435,16 +435,32 @@ sal_Int64 SAL_CALL SvXMLImport::getSomething( const uno::Sequence< sal_Int8 >& r
return 0;
}
+namespace
+{
+ class setFastDocumentHandlerGuard
+ {
+ private:
+ css::uno::Reference<css::xml::sax::XFastParser> mxParser;
+ public:
+ setFastDocumentHandlerGuard(const css::uno::Reference<css::xml::sax::XFastParser>& Parser,
+ const css::uno::Reference<css::xml::sax::XFastDocumentHandler>& Handler)
+ : mxParser(Parser)
+ {
+ mxParser->setFastDocumentHandler(Handler);
+ }
+ //guarantee restoration of null document handler
+ ~setFastDocumentHandlerGuard()
+ {
+ mxParser->setFastDocumentHandler(nullptr);
+ }
+ };
+}
+
// XFastParser
void SAL_CALL SvXMLImport::parseStream( const xml::sax::InputSource& aInputSource )
{
- if ( mxFastDocumentHandler.is() )
- mxParser->setFastDocumentHandler( mxFastDocumentHandler );
- else
- mxParser->setFastDocumentHandler( this );
-
- mxParser->parseStream( aInputSource );
- mxParser->setFastDocumentHandler( nullptr );
+ setFastDocumentHandlerGuard aDocumentHandlerGuard(mxParser, mxFastDocumentHandler.is() ? mxFastDocumentHandler : this);
+ mxParser->parseStream(aInputSource);
}
void SAL_CALL SvXMLImport::setFastDocumentHandler( const uno::Reference< xml::sax::XFastDocumentHandler >& Handler )
More information about the Libreoffice-commits
mailing list