From 9c44900e680c6967b94005e908f4bc1a0584a53c Mon Sep 17 00:00:00 2001
From: Julian Bouzas <julian.bouzas@collabora.com>
Date: Tue, 17 Mar 2020 12:06:21 -0400
Subject: [PATCH] config-policy: fix endpoint refcount issues

---
 modules/module-config-policy/config-policy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/module-config-policy/config-policy.c b/modules/module-config-policy/config-policy.c
index 4a726891..09988859 100644
--- a/modules/module-config-policy/config-policy.c
+++ b/modules/module-config-policy/config-policy.c
@@ -174,7 +174,7 @@ wp_config_policy_handle_pending_link (WpConfigPolicy *self,
       /* linked to the wrong target so unlink and continue */
       g_debug ("Unlinking endpoint '%s' from its previous target",
           wp_base_endpoint_get_name (li->ep));
-      WpBaseEndpoint *ep = wp_base_endpoint_link_get_sink_endpoint (l);
+      g_autoptr (WpBaseEndpoint) ep = wp_base_endpoint_link_get_sink_endpoint (l);
       guint32 stream_id = wp_base_endpoint_link_get_sink_stream (l);
       fade_out (ep, stream_id, on_faded_destroy_link, l);
     }
@@ -186,7 +186,7 @@ wp_config_policy_handle_pending_link (WpConfigPolicy *self,
     for (guint i = 0; i < links->len; i++) {
       WpBaseEndpointLink *l = g_ptr_array_index (links, i);
       if (!wp_base_endpoint_link_is_kept (l)) {
-        WpBaseEndpoint *ep = wp_base_endpoint_link_get_sink_endpoint (l);
+        g_autoptr (WpBaseEndpoint) ep = wp_base_endpoint_link_get_sink_endpoint (l);
         guint32 stream_id = wp_base_endpoint_link_get_sink_stream (l);
         fade_out (ep, stream_id, on_faded_destroy_link, l);
       }
@@ -397,7 +397,7 @@ wp_config_policy_add_link_info (WpConfigPolicy *self, GHashTable *table,
   const struct WpParserEndpointLinkData *data = NULL;
   const char *ep_role = wp_base_endpoint_get_role (ep);
   struct link_info *res = NULL;
-  WpBaseEndpoint *target = NULL;
+  g_autoptr (WpBaseEndpoint) target = NULL;
   guint32 stream_id = WP_STREAM_ID_NONE;
 
   /* Get the parser for the endpoint-link extension */
@@ -425,7 +425,7 @@ wp_config_policy_add_link_info (WpConfigPolicy *self, GHashTable *table,
   if (!link_infos) {
     link_infos = g_ptr_array_new_with_free_func (link_info_destroy);
     g_ptr_array_add (link_infos, res);
-    g_hash_table_insert (table, g_object_ref (target), link_infos);
+    g_hash_table_insert (table, g_steal_pointer (&target), link_infos);
   } else {
     g_ptr_array_add (link_infos, res);
   }
-- 
GitLab