summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2012-12-30 14:05:28 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2013-01-23 10:03:27 +0100
commit7f16a0713763a0580f7762eec670a82c2d687937 (patch)
treebae8b0bdaed8b412d159730d8e33caf357e6ce48 /examples
parent2780e7690176c8dee53f457f9b54ba6fc8fb3be5 (diff)
virtxml: Fix various memory leaks
All memory was not cleaned up properly upon exit, and a string could be leaked from guess_os_from_disk when we issue a continue/break early during the loop iteration.
Diffstat (limited to 'examples')
-rw-r--r--examples/virtxml.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/examples/virtxml.c b/examples/virtxml.c
index d719e5f..e577911 100644
--- a/examples/virtxml.c
+++ b/examples/virtxml.c
@@ -369,6 +369,10 @@ guess_os_from_disk(GList *disk_list)
path = g_strndup(path, sep-path);
media = osinfo_media_create_from_location(path, NULL, NULL);
+
+ if (sep)
+ g_free(path);
+
if (!media)
continue;
@@ -376,9 +380,6 @@ guess_os_from_disk(GList *disk_list)
g_object_get(G_OBJECT(media), "os", &ret, NULL);
break;
}
-
- if (sep)
- g_free(path);
}
return ret;
@@ -595,12 +596,22 @@ main(int argc, char *argv[])
xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(config));
g_printf("%s\n", xml);
+ g_free(xml);
ret = EXIT_SUCCESS;
cleanup:
+ if (os)
+ g_object_unref(G_OBJECT(os));
+ if (platform)
+ g_object_unref(G_OBJECT(platform));
+ if (caps)
+ g_object_unref(G_OBJECT(caps));
+ if (domain)
+ g_object_unref(G_OBJECT(domain));
if (conn)
gvir_connection_close(conn);
+
return ret;
}