[gnome-control-center/wip/applications] Fix a small memory leak
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/applications] Fix a small memory leak
- Date: Sat, 5 Jan 2019 22:22:26 +0000 (UTC)
commit 25ee6719cc14aaf1de4e5286077e74a05c146463
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jan 5 17:19:51 2019 -0500
Fix a small memory leak
When jumping out of a g_variant_iter_loop-driven loop,
care must be taken to free the variables that are
managed by that function for regular loop termination.
panels/applications/cc-applications-panel.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/panels/applications/cc-applications-panel.c b/panels/applications/cc-applications-panel.c
index e5dbce0e9..4d61155fe 100644
--- a/panels/applications/cc-applications-panel.c
+++ b/panels/applications/cc-applications-panel.c
@@ -166,9 +166,8 @@ get_flatpak_permissions (CcApplicationsPanel *self,
{
g_autoptr(GVariant) ret = NULL;
g_autoptr(GVariantIter) iter = NULL;
- g_auto(GStrv) permissions = NULL;
- GVariant *val;
- gchar *key;
+ g_autoptr(GVariant) val = NULL;
+ g_autofree gchar *key = NULL;
ret = g_dbus_proxy_call_sync (self->perm_store,
"Lookup",
@@ -182,13 +181,13 @@ get_flatpak_permissions (CcApplicationsPanel *self,
while (g_variant_iter_loop (iter, "{s@as}", &key, &val))
{
if (strcmp (key, app_id) == 0)
- {
- permissions = g_variant_dup_strv (val, NULL);
- break;
- }
+ return g_variant_dup_strv (val, NULL);
}
- return g_steal_pointer (&permissions);
+ val = NULL; /* freed by g_variant_iter_loop */
+ key = NULL;
+
+ return NULL;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]