[libvirt] [PATCH 2/2] virtxml: Always initialize 'list'

Christophe Fergeau cfergeau at redhat.com
Wed Sep 12 15:42:51 UTC 2012


'list' is freed in error cases, and in the 2 functions modified by
this commit, we may jump to the error: label before 'list' is
initialized when 'db' is NULL.
---
 examples/virtxml.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/virtxml.c b/examples/virtxml.c
index 9783ba6..b0c3a77 100644
--- a/examples/virtxml.c
+++ b/examples/virtxml.c
@@ -97,7 +97,7 @@ print_oses(const gchar *option_name,
            GError **error)
 {
     OsinfoDb *db = get_default_osinfo_db();
-    OsinfoOsList *list;
+    OsinfoOsList *list = NULL;
     GList *oses = NULL;
     GList *os_iter;
     int ret = EXIT_FAILURE;
@@ -140,7 +140,7 @@ print_platforms(const gchar *option_name,
                 GError **error)
 {
     OsinfoDb *db = get_default_osinfo_db();
-    OsinfoPlatformList *list;
+    OsinfoPlatformList *list = NULL;
     GList *platforms = NULL;
     GList *platform_iter;
     int ret = EXIT_FAILURE;
-- 
1.7.11.4




More information about the libvir-list mailing list