tools/qa/cppunit/test_xpath.cxx |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 7d1b4abc5402a8c3edd7fb2b6da1cd0af8691b8a
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Dec 23 13:05:14 2025 +0900
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Tue Dec 23 07:44:11 2025 +0100

    tools: destroy objects in the correct order in XPathTest
    
    Use xmlDocUniquePtr in XPathTest instead of manually handling the
    pointers and deleting it with xmlFreeDoc function at the end. This
    causes that the objects are not deleted in the correct order.
    
    Change-Id: I9933dc3f354c1374a2e53c9f65ff98b5e6a443c6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196144
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    Tested-by: Jenkins

diff --git a/tools/qa/cppunit/test_xpath.cxx b/tools/qa/cppunit/test_xpath.cxx
index 3cbc29c90ff8..03726b2dc869 100644
--- a/tools/qa/cppunit/test_xpath.cxx
+++ b/tools/qa/cppunit/test_xpath.cxx
@@ -10,6 +10,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 #include <test/bootstrapfixture.hxx>
 #include <rtl/ustring.hxx>
+#include <test/xmldocptr.hxx>
 #include <tools/stream.hxx>
 #include <tools/XPath.hxx>
 
@@ -36,10 +37,11 @@ public:
         pBuffer[nSize] = 0;
         aFileStream.ReadBytes(pBuffer.get(), nSize);
         auto pCharBuffer = reinterpret_cast<xmlChar*>(pBuffer.get());
-        xmlDocPtr pXmlDoc
-            = xmlReadDoc(pCharBuffer, nullptr, nullptr, XML_PARSE_NODICT | 
XML_PARSE_HUGE);
 
-        tools::XPath aXPath(pXmlDoc);
+        xmlDocUniquePtr pXmlDoc(
+            xmlReadDoc(pCharBuffer, nullptr, nullptr, XML_PARSE_NODICT | 
XML_PARSE_HUGE));
+
+        tools::XPath aXPath(pXmlDoc.get());
         auto aNonExistentPath = aXPath.create("/nonexistent");
         CPPUNIT_ASSERT(aNonExistentPath);
         CPPUNIT_ASSERT_EQUAL(0, aNonExistentPath->count());
@@ -80,8 +82,6 @@ public:
         CPPUNIT_ASSERT_EQUAL(u"Content"_ustr, aGrandChildResult->content());
         CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, 
aGrandChildResult->attribute("attribute1"));
         CPPUNIT_ASSERT_EQUAL(u"CDE"_ustr, 
aGrandChildResult->attribute("attribute2"));
-
-        xmlFreeDoc(pXmlDoc);
     }
 
     CPPUNIT_TEST_SUITE(XPathTest);

Reply via email to