free as much as possible on return from get_string_from_xpath
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
src/libvirt-php.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 8588128..18499a6 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -2597,6 +2597,7 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int
*retVal)
if (!doc) {
if (retVal)
*retVal = -2;
+ xmlFreeParserCtxt(xp);
xmlCleanupParser();
return NULL;
}
@@ -2605,6 +2606,8 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int
*retVal)
if (!context) {
if (retVal)
*retVal = -3;
+ xmlFreeDoc(doc);
+ xmlFreeParserCtxt(xp);
xmlCleanupParser();
return NULL;
}
@@ -2614,6 +2617,8 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int
*retVal)
if (retVal)
*retVal = -4;
xmlXPathFreeContext(context);
+ xmlFreeParserCtxt(xp);
+ xmlFreeDoc(doc);
xmlCleanupParser();
return NULL;
}
@@ -2621,6 +2626,8 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int
*retVal)
if(xmlXPathNodeSetIsEmpty(result->nodesetval)){
xmlXPathFreeObject(result);
xmlXPathFreeContext(context);
+ xmlFreeParserCtxt(xp);
+ xmlFreeDoc(doc);
xmlCleanupParser();
if (retVal)
*retVal = 0;
@@ -2632,8 +2639,9 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int
*retVal)
if (ret == 0) {
xmlXPathFreeObject(result);
- xmlFreeDoc(doc);
xmlXPathFreeContext(context);
+ xmlFreeParserCtxt(xp);
+ xmlFreeDoc(doc);
xmlCleanupParser();
if (retVal)
*retVal = 0;
@@ -2658,8 +2666,9 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int
*retVal)
value = (char *)xmlNodeListGetString(doc,
nodeset->nodeTab[0]->xmlChildrenNode, 1);
}
- xmlXPathFreeContext(context);
xmlXPathFreeObject(result);
+ xmlXPathFreeContext(context);
+ xmlFreeParserCtxt(xp);
xmlFreeDoc(doc);
xmlCleanupParser();
--
2.5.0