Always drop the reference of the ATContext
authorLukáš Tyrychtr <ltyrycht@redhat.com>
Thu, 16 Mar 2023 16:15:08 +0000 (17:15 +0100)
committerLukáš Tyrychtr <ltyrycht@redhat.com>
Thu, 16 Mar 2023 16:15:08 +0000 (17:15 +0100)
gtk/gtkaccessible.c

index 16bafe3fb765ecfdbe509f0a621d51b5307a546d..dad85e2e00897997846a385584b1cfcf3dc6b5e7 100644 (file)
@@ -249,22 +249,21 @@ gtk_accessible_get_next_accessible_sibling (GtkAccessible *self)
   g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), NULL);
 
   GtkATContext *context;
+  GtkAccessible *sibling = NULL;
 
   context = gtk_accessible_get_at_context (self);
   if (context != NULL && gtk_at_context_get_accessible_parent (context) != NULL)
     {
-      GtkAccessible *sibling = NULL;
-
       sibling = gtk_at_context_get_next_accessible_sibling (context);
       if (sibling != NULL)
         sibling = g_object_ref (sibling);
-
-      g_object_unref (context);
-
-      return sibling;
     }
   else
-    return GTK_ACCESSIBLE_GET_IFACE (self)->get_next_accessible_sibling (self);
+    sibling = GTK_ACCESSIBLE_GET_IFACE (self)->get_next_accessible_sibling (self);
+
+  g_clear_object (&context);
+
+  return sibling;
 }
 
 /**