[epiphany/gnome-3-24] permissions-manager: Fix leak in error path



commit 1515d94ffe7b7b00dba4b2969a6897038c1499f6
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Fri Sep 1 08:54:40 2017 -0500

    permissions-manager: Fix leak in error path

 lib/ephy-permissions-manager.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/lib/ephy-permissions-manager.c b/lib/ephy-permissions-manager.c
index 454efc7..101156a 100644
--- a/lib/ephy-permissions-manager.c
+++ b/lib/ephy-permissions-manager.c
@@ -354,7 +354,7 @@ ephy_permissions_manager_get_matching_origins (EphyPermissionsManager *manager,
 {
   GKeyFile *file;
   char *filename;
-  char **groups;
+  char **groups = NULL;
   gsize groups_length;
   GList *origins = NULL;
   GError *error = NULL;
@@ -380,7 +380,7 @@ ephy_permissions_manager_get_matching_origins (EphyPermissionsManager *manager,
     if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
       g_warning ("Error processing %s: %s", filename, error->message);
     g_error_free (error);
-    return NULL;
+    goto out;
   }
 
   groups = g_key_file_get_groups (file, &groups_length);
@@ -388,10 +388,6 @@ ephy_permissions_manager_get_matching_origins (EphyPermissionsManager *manager,
     origins = g_list_concat (origins,
                              origins_for_keyfile_group (file, filename, groups[i], type, permit));
 
-  g_key_file_unref (file);
-  g_strfreev (groups);
-  g_free (filename);
-
   /* Cache the results. */
   if (origins != NULL) {
     g_hash_table_insert (permit ? manager->permission_type_permitted_origins
@@ -400,6 +396,11 @@ ephy_permissions_manager_get_matching_origins (EphyPermissionsManager *manager,
                          origins);
   }
 
+out:
+  g_key_file_unref (file);
+  g_strfreev (groups);
+  g_free (filename);
+
   return origins;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]