From ecad76d9953aa293f3fb8b810bbf05dc1215a6d4 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis <george.kiagiadakis@collabora.com> Date: Tue, 18 Jun 2019 11:38:14 +0300 Subject: [PATCH] policy: consume floating reference of GVariant in _find_endpoint() --- lib/wp/policy.c | 5 ++++- modules/module-simple-policy.c | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/wp/policy.c b/lib/wp/policy.c index 45b8161c..1e05cf70 100644 --- a/lib/wp/policy.c +++ b/lib/wp/policy.c @@ -346,7 +346,7 @@ wp_policy_notify_changed (WpPolicy *self) /** * wp_policy_find_endpoint: * @core: the #WpCore - * @props: properties of the lookup + * @props: (transfer floating): properties of the lookup * @stream_id: (out): the relevant stream id of the returned endpoint * * Calls #WpPolicyClass::find_endpoint on all policies, in order, until @@ -378,5 +378,8 @@ wp_policy_find_endpoint (WpCore *core, GVariant *props, } } + if (g_variant_is_floating (props)) + g_variant_unref (props); + return NULL; } diff --git a/modules/module-simple-policy.c b/modules/module-simple-policy.c index 44032923..ff3f6132 100644 --- a/modules/module-simple-policy.c +++ b/modules/module-simple-policy.c @@ -26,7 +26,6 @@ simple_policy_handle_endpoint (WpPolicy *policy, WpEndpoint *ep) { const char *media_class = NULL; GVariantDict d; - g_autoptr (GVariant) props = NULL; g_autoptr (WpCore) core = NULL; g_autoptr (WpEndpoint) target = NULL; g_autoptr (GError) error = NULL; @@ -42,10 +41,9 @@ simple_policy_handle_endpoint (WpPolicy *policy, WpEndpoint *ep) g_variant_dict_insert (&d, "action", "s", "link"); g_variant_dict_insert (&d, "media.class", "s", "Audio/Sink"); /* TODO: more properties are needed here */ - props = g_variant_dict_end (&d); core = wp_policy_get_core (policy); - target = wp_policy_find_endpoint (core, props, &stream_id); + target = wp_policy_find_endpoint (core, g_variant_dict_end (&d), &stream_id); if (!target) { g_warning ("Could not find an Audio/Sink target endpoint\n"); /* TODO: we should kill the client, otherwise it's going to hang waiting */ -- GitLab