[Libosinfo] [PATCH 3/8] test-isodetect: Fix GFileInfo leak
Daniel P. Berrange
berrange at redhat.com
Thu Nov 5 16:55:46 UTC 2015
On Thu, Nov 05, 2015 at 05:20:41PM +0100, Christophe Fergeau wrote:
> This fixes:
> ==12890== 10,438 (520 direct, 9,918 indirect) bytes in 13 blocks are definitely lost in loss record 2,151
> ==12890== at 0x4C28C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==12890== by 0x6A514D8: g_malloc (in /usr/lib64/libglib-2.0.so.0.4600.1)
> ==12890== by 0x6A68622: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.4600.1)
> ==12890== by 0x6A68CBD: g_slice_alloc0 (in /usr/lib64/libglib-2.0.so.0.4600.1)
> ==12890== by 0x67E2B63: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.4600.1)
> ==12890== by 0x67C4B7A: ??? (in /usr/lib64/libgobject-2.0.so.0.4600.1)
> ==12890== by 0x67C6460: g_object_newv (in /usr/lib64/libgobject-2.0.so.0.4600.1)
> ==12890== by 0x67C6D93: g_object_new (in /usr/lib64/libgobject-2.0.so.0.4600.1)
> ==12890== by 0x652836D: ??? (in /usr/lib64/libgio-2.0.so.0.4600.1)
> ==12890== by 0x652587B: ??? (in /usr/lib64/libgio-2.0.so.0.4600.1)
> ==12890== by 0x6481253: g_file_enumerator_next_file (in /usr/lib64/libgio-2.0.so.0.4600.1)
> ==12890== by 0x402B7A: load_distros (test-isodetect.c:246)
> ==12890== by 0x402C51: load_isos (test-isodetect.c:283)
> ==12890== by 0x403058: test_one (test-isodetect.c:331)
> ==12890== by 0x4033B8: test_windows (test-isodetect.c:387)
> ==12890== by 0x532B78A: tcase_run_tfun_nofork.isra.9 (check_run.c:390)
> ==12890== by 0x532BB7C: srunner_iterate_tcase_tfuns (check_run.c:231)
> ==12890== by 0x532BB7C: srunner_run_tcase (check_run.c:373)
> ==12890== by 0x532BB7C: srunner_iterate_suites (check_run.c:195)
> ==12890== by 0x532BB7C: srunner_run (check_run.c:782)
> ==12890== by 0x4037B9: main (test-isodetect.c:496)
> ---
> test/test-isodetect.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/test/test-isodetect.c b/test/test-isodetect.c
> index 666357a..912f79b 100644
> --- a/test/test-isodetect.c
> +++ b/test/test-isodetect.c
> @@ -194,12 +194,15 @@ static GList *load_distro(GFile *dir, const gchar *shortid, GError **error) {
> return NULL;
>
> while ((childinfo = g_file_enumerator_next_file(children, NULL, error)) != NULL) {
> - if (g_file_info_get_file_type(childinfo) !=
> - G_FILE_TYPE_REGULAR)
> + if (g_file_info_get_file_type(childinfo) != G_FILE_TYPE_REGULAR) {
> + g_object_unref(childinfo);
> continue;
> + }
>
> - if (!g_str_has_suffix(g_file_info_get_name(childinfo), ".txt"))
> + if (!g_str_has_suffix(g_file_info_get_name(childinfo), ".txt")) {
> + g_object_unref(childinfo);
> continue;
> + }
>
> GFile *child = g_file_get_child(dir, g_file_info_get_name(childinfo));
> struct ISOInfo *iso = load_iso(child,
> @@ -207,6 +210,7 @@ static GList *load_distro(GFile *dir, const gchar *shortid, GError **error) {
> g_file_info_get_name(childinfo),
> error);
> g_object_unref(child);
> + g_object_unref(childinfo);
>
> if (!iso)
> goto error;
> @@ -244,14 +248,16 @@ static GList *load_distros(GFile *dir, GError **error)
> return NULL;
>
> while ((childinfo = g_file_enumerator_next_file(children, NULL, error)) != NULL) {
> - if (g_file_info_get_file_type(childinfo) !=
> - G_FILE_TYPE_DIRECTORY)
> + if (g_file_info_get_file_type(childinfo) != G_FILE_TYPE_DIRECTORY) {
> + g_object_unref(childinfo);
> continue;
> + }
>
> GFile *child = g_file_get_child(dir, g_file_info_get_name(childinfo));
> GList *isos = load_distro(child, g_file_info_get_name(childinfo), error);
>
> g_object_unref(child);
> + g_object_unref(childinfo);
>
> if (!isos && *error)
> goto error;
ACK
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the Libosinfo
mailing list