[gtk/wip/baedert/for-master: 7/12] accessible: Fix memory leak if context is unset




commit 42d4c19e0a7e3f5f299a92d21b92c87724fd5966
Author: Timm Bäder <mail baedert org>
Date:   Sat Jan 9 15:07:21 2021 +0100

    accessible: Fix memory leak if context is unset
    
    Unref the acessible values

 gtk/gtkaccessible.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c
index ed89fa9714..c5934c80f8 100644
--- a/gtk/gtkaccessible.c
+++ b/gtk/gtkaccessible.c
@@ -496,12 +496,12 @@ gtk_accessible_update_relation_value (GtkAccessible         *self,
                                       GtkAccessibleRelation  relations[],
                                       const GValue           values[])
 {
+  GtkATContext *context;
+
   g_return_if_fail (GTK_IS_ACCESSIBLE (self));
   g_return_if_fail (n_relations > 0);
 
-  GtkATContext *context = gtk_accessible_get_at_context (self);
-  if (context == NULL)
-    return;
+  context = gtk_accessible_get_at_context (self);
 
   for (int i = 0; i < n_relations; i++)
     {
@@ -520,13 +520,15 @@ gtk_accessible_update_relation_value (GtkAccessible         *self,
           break;
         }
 
-      gtk_at_context_set_accessible_relation (context, relation, real_value);
+      if (context)
+        gtk_at_context_set_accessible_relation (context, relation, real_value);
 
       if (real_value != NULL)
         gtk_accessible_value_unref (real_value);
     }
 
-  gtk_at_context_update (context);
+  if (context)
+    gtk_at_context_update (context);
 }
 
 /**


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