[Libosinfo] [PATCH 09/14] install-script: Fix leak in error case in generate_entity_xml()

Christophe Fergeau cfergeau at redhat.com
Wed Jun 8 10:01:13 UTC 2016


The key list returned by osinfo_entity_get_param_keys() was freed in the
nominal case, but not in the error case.
---
 osinfo/osinfo_install_script.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index a290d2a..23831c5 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -662,7 +662,7 @@ static xmlNodePtr osinfo_install_script_generate_entity_xml(OsinfoInstallScript
 {
     xmlNodePtr node = NULL;
     xmlNodePtr data = NULL;
-    GList *keys;
+    GList *keys = NULL;
     GList *tmp1;
 
     if (!(node = xmlNewDocNode(NULL, NULL, (xmlChar*)name, NULL))) {
@@ -725,6 +725,7 @@ static xmlNodePtr osinfo_install_script_generate_entity_xml(OsinfoInstallScript
     return node;
 
  error:
+    g_list_free(keys);
     xmlFreeNode(data);
     xmlFreeNode(node);
     return NULL;
-- 
2.7.4




More information about the Libosinfo mailing list