[libvirt-glib 1/2] config: Fix gvir_config_xml_node_to_string() leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If xmlNodeDump() fails, we would be leaking the xmlBuffer we created.
This commit ensures we don't return early before this buffer is freed.
---
 libvirt-gconfig/libvirt-gconfig-helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-helpers.c b/libvirt-gconfig/libvirt-gconfig-helpers.c
index 0314a72..e8f9664 100644
--- a/libvirt-gconfig/libvirt-gconfig-helpers.c
+++ b/libvirt-gconfig/libvirt-gconfig-helpers.c
@@ -293,7 +293,7 @@ gvir_config_xml_node_to_string(xmlNodePtr node)
 
     xmlbuf = xmlBufferCreate();
     if (xmlNodeDump(xmlbuf, node->doc, node, 0, 1) < 0)
-        return NULL;
+        xml = NULL;
     else
         xml = g_strndup((gchar *)xmlBufferContent(xmlbuf), xmlBufferLength(xmlbuf));
 
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]