From ec6eaa58addf0d8823f8c56d4ec168ff389da8c5 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 5 May 2020 19:10:16 +0200 Subject: 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 --- starmath/qa/extras/mmlexport-test.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'starmath/qa') diff --git a/starmath/qa/extras/mmlexport-test.cxx b/starmath/qa/extras/mmlexport-test.cxx index 737885d5f73e..18732e09abb1 100644 --- a/starmath/qa/extras/mmlexport-test.cxx +++ b/starmath/qa/extras/mmlexport-test.cxx @@ -49,7 +49,7 @@ protected: virtual void registerNamespaces(xmlXPathContextPtr &pXmlXPathCtx) override; private: - xmlDocPtr exportAndParse(); + xmlDocUniquePtr exportAndParse(); SmDocShellRef mxDocShell; }; @@ -75,7 +75,7 @@ void MathMLExportTest::registerNamespaces(xmlXPathContextPtr &pXmlXPathCtx) xmlXPathRegisterNs(pXmlXPathCtx, BAD_CAST("m"), BAD_CAST("http://www.w3.org/1998/Math/MathML")); } -xmlDocPtr MathMLExportTest::exportAndParse() +xmlDocUniquePtr MathMLExportTest::exportAndParse() { utl::TempFile aTempFile; aTempFile.EnableKillingFile(); @@ -84,7 +84,7 @@ xmlDocPtr MathMLExportTest::exportAndParse() aStoreMedium.SetFilter(pExportFilter); CPPUNIT_ASSERT(mxDocShell->ConvertTo(aStoreMedium)); aStoreMedium.Commit(); - xmlDocPtr pDoc = parseXml(aTempFile); + xmlDocUniquePtr pDoc = parseXml(aTempFile); CPPUNIT_ASSERT(pDoc); return pDoc; } @@ -92,7 +92,7 @@ xmlDocPtr MathMLExportTest::exportAndParse() void MathMLExportTest::testBlank() { mxDocShell->SetText("x`y~~z"); - xmlDocPtr pDoc = exportAndParse(); + xmlDocUniquePtr pDoc = exportAndParse(); assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mspace[1]", "width", "0.5em"); assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mspace[2]", "width", "4em"); } @@ -100,7 +100,7 @@ void MathMLExportTest::testBlank() void MathMLExportTest::testTdf97049() { mxDocShell->SetText("intd {{1 over x} dx}"); - xmlDocPtr pDoc = exportAndParse(); + xmlDocUniquePtr pDoc = exportAndParse(); assertXPath(pDoc, "/m:math/m:semantics/m:mrow/m:mo[1]", "stretchy", "true"); auto aContent = getXPathContent(pDoc, "/m:math/m:semantics/m:mrow/m:mo[1]"); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aContent.getLength()); @@ -113,7 +113,7 @@ void MathMLExportTest::testTdf101022() { \ mxDocShell->SetText("%GAMMA %iGAMMA {ital %GAMMA} {nitalic %iGAMMA} " \ "%gamma %igamma {ital %gamma} {nitalic %igamma}"); \ - xmlDocPtr pDoc = exportAndParse(); \ + xmlDocUniquePtr pDoc = exportAndParse(); \ if (capital) \ assertXPathNoAttribute(pDoc, "/m:math/m:semantics/m:mrow/m:mi[1]", "mathvariant"); \ else \ -- cgit