diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-09-16 17:51:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-09-16 21:34:21 +0200 |
commit | 6c87ecfaafab362d2d95dbcd976ffb5ea957097e (patch) | |
tree | c49f9c2abc59c3f89b40dd63cb4d1050542489fe /xmloff/source | |
parent | a90a331a87c5cda888c765331baddf82aaabaa3c (diff) |
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@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 30 |
1 files changed, 23 insertions, 7 deletions
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 ) |