[glib] gfileenumerator: Don't leak memory if out_info is NULL
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gfileenumerator: Don't leak memory if out_info is NULL
- Date: Fri, 28 Aug 2015 12:19:11 +0000 (UTC)
commit f8341badb87ffc7d48488b95b58efbd1c7747674
Author: K. Adam Christensen <pope shifteleven com>
Date: Fri Aug 28 08:17:24 2015 -0400
gfileenumerator: Don't leak memory if out_info is NULL
In the unusual case where one just wants the filenames, avoid
a leak.
https://bugzilla.gnome.org/show_bug.cgi?id=754211
gio/gfileenumerator.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gio/gfileenumerator.c b/gio/gfileenumerator.c
index c0d2550..b07b88a 100644
--- a/gio/gfileenumerator.c
+++ b/gio/gfileenumerator.c
@@ -657,11 +657,6 @@ g_file_enumerator_iterate (GFileEnumerator *direnum,
if (ret_info)
{
- if (out_info != NULL)
- {
- g_object_set_qdata_full ((GObject*)direnum, cached_info_quark, ret_info,
(GDestroyNotify)g_object_unref);
- *out_info = ret_info;
- }
if (out_child != NULL)
{
const char *name = g_file_info_get_name (ret_info);
@@ -674,6 +669,13 @@ g_file_enumerator_iterate (GFileEnumerator *direnum,
g_object_set_qdata_full ((GObject*)direnum, cached_child_quark, *out_child,
(GDestroyNotify)g_object_unref);
}
}
+ if (out_info != NULL)
+ {
+ g_object_set_qdata_full ((GObject*)direnum, cached_info_quark, ret_info,
(GDestroyNotify)g_object_unref);
+ *out_info = ret_info;
+ }
+ else
+ g_object_unref (ret_info);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]