diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-05 19:10:16 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-07 09:52:27 +0200 |
commit | ec6eaa58addf0d8823f8c56d4ec168ff389da8c5 (patch) | |
tree | adb44639fc6bdecad5f576aa5e1aa90f3c9d64b3 /writerperfect | |
parent | c437948f6c0d602bb200fc92e80cb73ae8ae5109 (diff) |
fix memory leak of xmlDoc objects
in unit tests
Change-Id: Id16731bbbe2f1b0e3642722d77aba04fc98db4cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93508
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'writerperfect')
-rw-r--r-- | writerperfect/qa/unit/EPUBExportTest.cxx | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx index cf50d2d9da52..e6ca36fed947 100644 --- a/writerperfect/qa/unit/EPUBExportTest.cxx +++ b/writerperfect/qa/unit/EPUBExportTest.cxx @@ -40,7 +40,7 @@ class EPUBExportTest : public test::BootstrapFixture, protected: uno::Reference<lang::XComponent> mxComponent; utl::TempFile maTempFile; - xmlDocPtr mpXmlDoc = nullptr; + xmlDocUniquePtr mpXmlDoc; uno::Reference<packages::zip::XZipFileAccess2> mxZipFile; OUString maFilterOptions; @@ -50,7 +50,7 @@ public: void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override; void createDoc(const OUString& rFile, const uno::Sequence<beans::PropertyValue>& rFilterData); /// Returns an XML representation of the stream named rName in the exported package. - xmlDocPtr parseExport(const OUString& rName); + xmlDocUniquePtr parseExport(const OUString& rName); /// Parses a CSS representation of the stream named rName and returns it. std::map<OUString, std::vector<OUString>> parseCss(const OUString& rName); /// Looks up a key of a class in rCss. @@ -70,11 +70,7 @@ void EPUBExportTest::tearDown() if (mxComponent.is()) mxComponent->dispose(); - if (mpXmlDoc) - { - xmlFreeDoc(mpXmlDoc); - mpXmlDoc = nullptr; - } + mpXmlDoc.reset(); test::BootstrapFixture::tearDown(); } @@ -108,7 +104,7 @@ void EPUBExportTest::createDoc(const OUString& rFile, = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, maTempFile.GetURL()); } -xmlDocPtr EPUBExportTest::parseExport(const OUString& rName) +xmlDocUniquePtr EPUBExportTest::parseExport(const OUString& rName) { uno::Reference<io::XInputStream> xInputStream(mxZipFile->getByName(rName), uno::UNO_QUERY); std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); @@ -780,7 +776,6 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testPageSize) assertXPath(mpXmlDoc, "/xhtml:html/xhtml:head/xhtml:meta[@name='viewport']", "content", "width=816, height=1056"); - xmlFreeDoc(mpXmlDoc); mpXmlDoc = parseExport("OEBPS/images/image0001.svg"); // This was 288mm, logic->logic conversion input was a pixel value. assertXPath(mpXmlDoc, "/svg:svg", "width", "216mm"); @@ -835,8 +830,6 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTdf115623SplitByChapter) OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class"); CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); - xmlFreeDoc(mpXmlDoc); - mpXmlDoc = nullptr; } // Split HTML should keep the same writing-mode. { @@ -857,8 +850,6 @@ CPPUNIT_TEST_FIXTURE(EPUBExportTest, testTdf115623ManyPageSpans) OUString aClass = getXPath(mpXmlDoc, "//xhtml:body", "class"); CPPUNIT_ASSERT_EQUAL(OUString("vertical-rl"), EPUBExportTest::getCss(aCssDoc, aClass, "writing-mode")); - xmlFreeDoc(mpXmlDoc); - mpXmlDoc = nullptr; } { mpXmlDoc = parseExport("OEBPS/sections/section0002.xhtml"); |