[glib] Fix GError leak in g_file_query_writable_namespaces()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Fix GError leak in g_file_query_writable_namespaces()
- Date: Fri, 21 Aug 2015 04:45:09 +0000 (UTC)
commit 60a6ae6f0b84f059e33b8c658ef22c3d933db0a2
Author: Christophe Fergeau <cfergeau redhat com>
Date: Sun Mar 29 17:15:15 2015 +0200
Fix GError leak in g_file_query_writable_namespaces()
gvfs commit b358ca "Make sure metadata is always returned by
query_writable_namespaces()" changed the
query_writable_namespaces vfunc to never return NULL, but the error
checking in g_daemon_file_query_writable_namespaces still assumes vfunc
failure implies NULL return value and GError set. This causes a memory
leak as on failure the GError will be set but the vfunc implementation
will have created its own default list so NULL will not be returned, and
the GError will never be cleared.
This commit directly checks if the GError is set to detect failures,
my_error is directly dereferenced in the error block anyway.
This also removes an unneeded call to g_file_attribute_info_new(); as
the vfunc always returns us a non-NULL GFileAttributeInfoList.
https://bugzilla.gnome.org/show_bug.cgi?id=747364
gio/gfile.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/gio/gfile.c b/gio/gfile.c
index 0fd62f2..851be01 100644
--- a/gio/gfile.c
+++ b/gio/gfile.c
@@ -4337,9 +4337,14 @@ g_file_query_writable_namespaces (GFile *file,
if (list == NULL)
{
+ g_warn_if_reached();
+ list = g_file_attribute_info_list_new ();
+ }
+
+ if (my_error != NULL)
+ {
if (my_error->domain == G_IO_ERROR && my_error->code == G_IO_ERROR_NOT_SUPPORTED)
{
- list = g_file_attribute_info_list_new ();
g_error_free (my_error);
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]