[libvirt] [libvirt-php] free xml resources in get_string_from_xpath
by Vasiliy Tolstov
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
9 years, 1 month
[libvirt] [libvirt-php][PATCH 0/8] Couple of mem leak fixes
by Michal Privoznik
So, after I reviewed [1] I realized how big memory leaks we have there...
1: https://www.redhat.com/archives/libvir-list/2015-September/msg01045.html
Since there is nobody to review, I'm pushing this.
Michal Privoznik (8):
libvirt_network_get_information: Be more tolerant to missing info
examples: Resolve some warnings
examples: Rework a bit to resolve some warnings
Don't free() in RECREATE_STRING_WITH_E
LONGLONG_INIT: Reformat
virConnectGetHostname: free returned value
virDomainGetXMLDesc: Free returned value
virNodeDeviceGetXMLDesc: Free returned value
examples/index.php | 90 +++---
examples/libvirt.php | 44 +--
src/libvirt-php.c | 900 +++++++++++++++++++++++++--------------------------
3 files changed, 504 insertions(+), 530 deletions(-)
--
2.4.9
9 years, 1 month
[libvirt] [PATCH v2 0/3] Add support for gic-version machine option
by Pavel Fedin
qemu now supports gic-version option for the virt machine. This patchset
allows to use it in libvirt.
v1 => v2:
- Added capability flag
Pavel Fedin (3):
qemu: Introduce QEMU_CAPS_MACH_VIRT_GIC_VERSION capability
qemu: Add support for gic-version machine option
qemu: Add test cases for gic-version option
src/qemu/qemu_capabilities.c | 5 +++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 43 +++++++++++++++-------
.../qemuxml2argv-aarch64-gicv3.args | 6 +++
.../qemuxml2argv-aarch64-gicv3.xml | 26 +++++++++++++
tests/qemuxml2argvtest.c | 5 +++
6 files changed, 73 insertions(+), 13 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gicv3.xml
--
2.1.4
9 years, 1 month