summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-06-02 15:45:28 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-06-02 15:45:28 +0200
commitf87859b88f965a364804c22c1e81ca406df0e402 (patch)
tree43d40815ed22322a20e194bef683a4295eaf4d2d /sw
parent7e4a51ee504baedc9150a1c88c2a5ce7cd64bfbd (diff)
Fix memory leaks in test code
Change-Id: Ifa756a5da636e0b37654ad83900115872bc40f0e
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx12
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx23
2 files changed, 22 insertions, 13 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index aeb66e96463e..9c115a13e0f2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1541,7 +1541,8 @@ DECLARE_OOXMLEXPORT_TEST(testFontNameIsEmpty, "font-name-is-empty.docx")
xmlDocPtr pXmlFontTable = parseExport("word/fontTable.xml");
if (!pXmlFontTable)
return;
- xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlFontTable, "/w:fonts/w:font");
+ xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlFontTable, "/w:fonts/w:font");
+ xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
sal_Int32 length = xmlXPathNodeSetGetLength(pXmlNodes);
for(sal_Int32 index = 0; index < length; index++){
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[index];
@@ -1550,6 +1551,7 @@ DECLARE_OOXMLEXPORT_TEST(testFontNameIsEmpty, "font-name-is-empty.docx")
CPPUNIT_FAIL("Font name is empty.");
}
}
+ xmlXPathFreeObject(pXmlObj);
}
DECLARE_OOXMLEXPORT_TEST(testMultiColumnLineSeparator, "multi-column-line-separator-SAVED.docx")
@@ -2816,10 +2818,12 @@ DECLARE_OOXMLEXPORT_TEST(testGenericTextField, "Unsupportedtextfields.docx")
xmlDocPtr pXmlDoc = parseExport();
if (!pXmlDoc)
return;
- xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc,"/w:document/w:body/w:p[2]/w:r[2]/w:instrText");
+ xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc,"/w:document/w:body/w:p[2]/w:r[2]/w:instrText");
+ xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content));
CPPUNIT_ASSERT(contents.match("PRINTDATE \\* MERGEFORMAT"));
+ xmlXPathFreeObject(pXmlObj);
}
DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx")
@@ -2966,12 +2970,14 @@ DECLARE_OOXMLEXPORT_TEST(testCitation,"FDO74775.docx")
xmlDocPtr pXmlDoc = parseExport();
if (!pXmlDoc)
return;
- xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc,"/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[3]/w:instrText");
+ xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc,"/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[3]/w:instrText");
+ xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
CPPUNIT_ASSERT(pXmlNodes != 0);
CPPUNIT_ASSERT(pXmlNodes->nodeNr > 0);
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content));
CPPUNIT_ASSERT(contents.match(" CITATION [Kra06]"));
+ xmlXPathFreeObject(pXmlObj);
}
DECLARE_OOXMLEXPORT_TEST(testFdo76016, "fdo76016.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index b9610d0c00b9..ad5b49bb9b5f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -1519,8 +1519,10 @@ DECLARE_OOXMLEXPORT_TEST(testFdo76101, "fdo76101.docx")
if (!pXmlDoc)
return;
- xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, "/w:styles/w:style");
+ xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "/w:styles/w:style");
+ xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
CPPUNIT_ASSERT(4091 >= xmlXPathNodeSetGetLength(pXmlNodes));
+ xmlXPathFreeObject(pXmlObj);
}
DECLARE_OOXMLEXPORT_TEST(testSdtAndShapeOverlapping,"ShapeOverlappingWithSdt.docx")
@@ -1561,22 +1563,23 @@ DECLARE_OOXMLEXPORT_TEST(testAbsolutePositionOffsetValue,"fdo78432.docx")
sal_Int32 IntMax = SAL_MAX_INT32;
- xmlNodeSetPtr pXmlNodes[6];
- pXmlNodes[0] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionH[1]/wp:posOffset[1]");
- pXmlNodes[1] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionV[1]/wp:posOffset[1]");
+ xmlXPathObjectPtr pXmlObjs[6];
+ pXmlObjs[0] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionH[1]/wp:posOffset[1]");
+ pXmlObjs[1] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionV[1]/wp:posOffset[1]");
- pXmlNodes[2] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[2]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionH[1]/wp:posOffset[1]");
- pXmlNodes[3] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[2]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionV[1]/wp:posOffset[1]");
+ pXmlObjs[2] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[2]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionH[1]/wp:posOffset[1]");
+ pXmlObjs[3] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[2]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionV[1]/wp:posOffset[1]");
- pXmlNodes[4] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[3]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionH[1]/wp:posOffset[1]");
- pXmlNodes[5] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[3]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionV[1]/wp:posOffset[1]");
+ pXmlObjs[4] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[3]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionH[1]/wp:posOffset[1]");
+ pXmlObjs[5] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[3]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionV[1]/wp:posOffset[1]");
for(sal_Int32 index = 0; index<6; ++index)
{
- CPPUNIT_ASSERT(pXmlNodes[index] != 0);
- xmlNodePtr pXmlNode = pXmlNodes[index]->nodeTab[0];
+ CPPUNIT_ASSERT(pXmlObjs[index]->nodesetval != 0);
+ xmlNodePtr pXmlNode = pXmlObjs[index]->nodesetval->nodeTab[0];
OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content));
CPPUNIT_ASSERT( contents.toInt64() <= IntMax );
+ xmlXPathFreeObject(pXmlObjs[index]);
}
}