diff --git a/src/clipboard.c b/src/clipboard.c index 51879a317..305cffe98 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -115,7 +115,7 @@ handle_set_selection (XdpDbusClipboard *object, Call *call = call_from_invocation (invocation); Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; g_autoptr(GError) error = NULL; session = acquire_session_from_call (arg_session_handle, call); @@ -158,7 +158,7 @@ handle_set_selection (XdpDbusClipboard *object, g_dbus_method_invocation_return_gerror (invocation, error); return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); xdp_dbus_impl_clipboard_call_set_selection ( impl, arg_session_handle, options, NULL, NULL, NULL); diff --git a/src/dynamic-launcher.c b/src/dynamic-launcher.c index d29397ac1..d336babb8 100644 --- a/src/dynamic-launcher.c +++ b/src/dynamic-launcher.c @@ -453,7 +453,7 @@ set_launcher_data_for_token (const char *token, { g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&transient_permissions_lock); guint timeout_id; - GVariant *launcher_data_wrapped; + g_autoptr(GVariant) launcher_data_wrapped = NULL; if (!transient_permissions) { @@ -466,11 +466,12 @@ set_launcher_data_for_token (const char *token, */ timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 300, install_token_timeout, g_strdup (token), g_free); - launcher_data_wrapped = g_variant_new ("(vu)", launcher_data, timeout_id); + launcher_data_wrapped = + g_variant_ref_sink (g_variant_new ("(vu)", launcher_data, timeout_id)); g_hash_table_insert (transient_permissions, g_strdup (token), - g_variant_ref_sink (launcher_data_wrapped)); + g_steal_pointer (&launcher_data_wrapped)); } static void @@ -479,7 +480,6 @@ prepare_install_done (GObject *source, gpointer data) { g_autoptr(Request) request = data; - GVariant *launcher_data; guint response = 2; g_autoptr(GVariant) results = NULL; g_autoptr(GError) error = NULL; @@ -526,6 +526,8 @@ prepare_install_done (GObject *source, } else { + GVariant *launcher_data; + /* Save the token in memory and return it to the caller */ launcher_data = g_variant_new ("(svss)", chosen_name, chosen_icon, icon_format, icon_size); set_launcher_data_for_token (token, launcher_data); @@ -688,7 +690,6 @@ handle_request_install_token (XdpDbusDynamicLauncher *object, Call *call = call_from_invocation (invocation); const char *app_id = xdp_app_info_get_id (call->app_info); g_autoptr(GError) error = NULL; - GVariant *launcher_data; g_autofree char *token = NULL; g_autofree char *icon_format = NULL; g_autofree char *icon_size = NULL; @@ -718,6 +719,8 @@ handle_request_install_token (XdpDbusDynamicLauncher *object, if (response == 0) { + GVariant *launcher_data; + /* Do some validation on the icon before saving it */ if (!validate_serialized_icon (arg_icon_v, &icon_format, &icon_size)) { diff --git a/src/global-shortcuts.c b/src/global-shortcuts.c index ce5eb928f..4a2fea87b 100644 --- a/src/global-shortcuts.c +++ b/src/global-shortcuts.c @@ -237,7 +237,7 @@ handle_create_session (XdpDbusGlobalShortcuts *object, return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); impl_request = xdp_dbus_impl_request_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (impl)), G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, @@ -392,7 +392,7 @@ handle_bind_shortcuts (XdpDbusGlobalShortcuts *object, return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); g_variant_builder_init (&shortcuts_builder, G_VARIANT_TYPE_ARRAY); if (!xdp_verify_shortcuts (arg_shortcuts, &shortcuts_builder, @@ -402,7 +402,7 @@ handle_bind_shortcuts (XdpDbusGlobalShortcuts *object, g_dbus_method_invocation_return_gerror (invocation, error); return G_DBUS_METHOD_INVOCATION_HANDLED; } - shortcuts = g_variant_builder_end (&shortcuts_builder); + shortcuts = g_variant_ref_sink (g_variant_builder_end (&shortcuts_builder)); session = acquire_session (arg_session_handle, request); if (!session) @@ -519,7 +519,7 @@ handle_list_shortcuts (XdpDbusGlobalShortcuts *object, return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); session = acquire_session (arg_session_handle, request); if (!session) diff --git a/src/input-capture.c b/src/input-capture.c index 7b9bae801..24b773d92 100644 --- a/src/input-capture.c +++ b/src/input-capture.c @@ -235,7 +235,7 @@ handle_create_session (XdpDbusInputCapture *object, g_autoptr(XdpDbusImplRequest) impl_request = NULL; g_autoptr(GError) error = NULL; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; Session *session; REQUEST_AUTOLOCK (request); @@ -271,7 +271,7 @@ handle_create_session (XdpDbusInputCapture *object, g_dbus_method_invocation_return_gerror (invocation, error); return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); g_object_set_qdata_full (G_OBJECT (request), quark_request_session, @@ -327,12 +327,12 @@ get_zones_done (GObject *source_object, if (request->exported) { - if (response != 0) + if (!results) { GVariantBuilder results_builder; g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT); - results = g_variant_builder_end (&results_builder); + results = g_variant_ref_sink (g_variant_builder_end (&results_builder)); } xdp_dbus_request_emit_response (XDP_DBUS_REQUEST (request), response, results); @@ -359,7 +359,7 @@ handle_get_zones (XdpDbusInputCapture *object, InputCaptureSession *input_capture_session; g_autoptr(GError) error = NULL; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; Session *session; REQUEST_AUTOLOCK (request); @@ -427,7 +427,7 @@ handle_get_zones (XdpDbusInputCapture *object, return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); g_object_set_qdata_full (G_OBJECT (request), quark_request_session, @@ -488,7 +488,7 @@ set_pointer_barriers_done (GObject *source_object, GVariantBuilder results_builder; g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT); - results = g_variant_builder_end (&results_builder); + results = g_variant_ref_sink (g_variant_builder_end (&results_builder)); } xdp_dbus_request_emit_response (XDP_DBUS_REQUEST (request), response, results); @@ -515,7 +515,7 @@ handle_set_pointer_barriers (XdpDbusInputCapture *object, InputCaptureSession *input_capture_session; g_autoptr(GError) error = NULL; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; Session *session; REQUEST_AUTOLOCK (request); @@ -583,7 +583,7 @@ handle_set_pointer_barriers (XdpDbusInputCapture *object, return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); g_object_set_qdata_full (G_OBJECT (request), quark_request_session, diff --git a/src/remote-desktop.c b/src/remote-desktop.c index c8ac83d58..17e5fe2be 100644 --- a/src/remote-desktop.c +++ b/src/remote-desktop.c @@ -309,7 +309,7 @@ handle_create_session (XdpDbusRemoteDesktop *object, g_autoptr(XdpDbusImplRequest) impl_request = NULL; Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; REQUEST_AUTOLOCK (request); @@ -336,7 +336,7 @@ handle_create_session (XdpDbusRemoteDesktop *object, } g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT); - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); g_object_set_qdata_full (G_OBJECT (request), quark_request_session, @@ -514,7 +514,7 @@ handle_select_devices (XdpDbusRemoteDesktop *object, g_autoptr(GError) error = NULL; g_autoptr(XdpDbusImplRequest) impl_request = NULL; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; REQUEST_AUTOLOCK (request); @@ -566,7 +566,7 @@ handle_select_devices (XdpDbusRemoteDesktop *object, return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); /* If 'restore_token' is passed, lookup the corresponding data in the * permission store and / or the GHashTable with transient permissions. @@ -647,7 +647,7 @@ start_done (GObject *source_object, RemoteDesktopSession *remote_desktop_session; guint response = 2; gboolean should_close_session; - GVariant *results = NULL; + g_autoptr(GVariant) results = NULL; g_autoptr(GError) error = NULL; REQUEST_AUTOLOCK (request); @@ -690,7 +690,7 @@ start_done (GObject *source_object, GVariantBuilder results_builder; g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT); - results = g_variant_builder_end (&results_builder); + results = g_variant_ref_sink (g_variant_builder_end (&results_builder)); } xdp_dbus_request_emit_response (XDP_DBUS_REQUEST (request), @@ -722,7 +722,7 @@ handle_start (XdpDbusRemoteDesktop *object, g_autoptr(GError) error = NULL; g_autoptr(XdpDbusImplRequest) impl_request = NULL; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; REQUEST_AUTOLOCK (request); @@ -776,7 +776,7 @@ handle_start (XdpDbusRemoteDesktop *object, request_export (request, g_dbus_method_invocation_get_connection (invocation)); g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT); - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); g_object_set_qdata_full (G_OBJECT (request), quark_request_session, @@ -860,7 +860,7 @@ handle_notify_pointer_motion (XdpDbusRemoteDesktop *object, Call *call = call_from_invocation (invocation); Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; g_autoptr(GError) error = NULL; session = acquire_session_from_call (arg_session_handle, call); @@ -893,7 +893,7 @@ handle_notify_pointer_motion (XdpDbusRemoteDesktop *object, g_dbus_method_invocation_return_gerror (invocation, error); return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); xdp_dbus_impl_remote_desktop_call_notify_pointer_motion (impl, session->id, @@ -918,7 +918,7 @@ handle_notify_pointer_motion_absolute (XdpDbusRemoteDesktop *object, Call *call = call_from_invocation (invocation); Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; g_autoptr(GError) error = NULL; session = acquire_session_from_call (arg_session_handle, call); @@ -961,7 +961,7 @@ handle_notify_pointer_motion_absolute (XdpDbusRemoteDesktop *object, return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); xdp_dbus_impl_remote_desktop_call_notify_pointer_motion_absolute (impl, session->id, @@ -986,7 +986,7 @@ handle_notify_pointer_button (XdpDbusRemoteDesktop *object, Call *call = call_from_invocation (invocation); Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; g_autoptr(GError) error = NULL; session = acquire_session_from_call (arg_session_handle, call); @@ -1020,7 +1020,7 @@ handle_notify_pointer_button (XdpDbusRemoteDesktop *object, return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); xdp_dbus_impl_remote_desktop_call_notify_pointer_button (impl, session->id, @@ -1049,7 +1049,7 @@ handle_notify_pointer_axis (XdpDbusRemoteDesktop *object, Call *call = call_from_invocation (invocation); Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; g_autoptr(GError) error = NULL; session = acquire_session_from_call (arg_session_handle, call); @@ -1083,7 +1083,7 @@ handle_notify_pointer_axis (XdpDbusRemoteDesktop *object, return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); xdp_dbus_impl_remote_desktop_call_notify_pointer_axis (impl, session->id, @@ -1107,7 +1107,7 @@ handle_notify_pointer_axis_discrete (XdpDbusRemoteDesktop *object, Call *call = call_from_invocation (invocation); Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; g_autoptr(GError) error = NULL; session = acquire_session_from_call (arg_session_handle, call); @@ -1140,7 +1140,7 @@ handle_notify_pointer_axis_discrete (XdpDbusRemoteDesktop *object, g_dbus_method_invocation_return_gerror (invocation, error); return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); xdp_dbus_impl_remote_desktop_call_notify_pointer_axis_discrete (impl, session->id, @@ -1165,7 +1165,7 @@ handle_notify_keyboard_keycode (XdpDbusRemoteDesktop *object, Call *call = call_from_invocation (invocation); Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; g_autoptr(GError) error = NULL; session = acquire_session_from_call (arg_session_handle, call); @@ -1198,7 +1198,7 @@ handle_notify_keyboard_keycode (XdpDbusRemoteDesktop *object, g_dbus_method_invocation_return_gerror (invocation, error); return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); xdp_dbus_impl_remote_desktop_call_notify_keyboard_keycode (impl, session->id, @@ -1223,7 +1223,7 @@ handle_notify_keyboard_keysym (XdpDbusRemoteDesktop *object, Call *call = call_from_invocation (invocation); Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; g_autoptr(GError) error = NULL; session = acquire_session_from_call (arg_session_handle, call); @@ -1256,7 +1256,7 @@ handle_notify_keyboard_keysym (XdpDbusRemoteDesktop *object, g_dbus_method_invocation_return_gerror (invocation, error); return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); xdp_dbus_impl_remote_desktop_call_notify_keyboard_keysym (impl, session->id, @@ -1283,7 +1283,7 @@ handle_notify_touch_down (XdpDbusRemoteDesktop *object, Call *call = call_from_invocation (invocation); Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; g_autoptr(GError) error = NULL; session = acquire_session_from_call (arg_session_handle, call); @@ -1325,7 +1325,7 @@ handle_notify_touch_down (XdpDbusRemoteDesktop *object, g_dbus_method_invocation_return_gerror (invocation, error); return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); xdp_dbus_impl_remote_desktop_call_notify_touch_down (impl, session->id, @@ -1353,7 +1353,7 @@ handle_notify_touch_motion (XdpDbusRemoteDesktop *object, Call *call = call_from_invocation (invocation); Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; g_autoptr(GError) error = NULL; session = acquire_session_from_call (arg_session_handle, call); @@ -1395,7 +1395,7 @@ handle_notify_touch_motion (XdpDbusRemoteDesktop *object, g_dbus_method_invocation_return_gerror (invocation, error); return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); xdp_dbus_impl_remote_desktop_call_notify_touch_motion (impl, session->id, @@ -1420,7 +1420,7 @@ handle_notify_touch_up (XdpDbusRemoteDesktop *object, Call *call = call_from_invocation (invocation); Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; g_autoptr(GError) error = NULL; session = acquire_session_from_call (arg_session_handle, call); @@ -1453,7 +1453,7 @@ handle_notify_touch_up (XdpDbusRemoteDesktop *object, g_dbus_method_invocation_return_gerror (invocation, error); return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); xdp_dbus_impl_remote_desktop_call_notify_touch_up (impl, session->id, diff --git a/src/restore-token.c b/src/restore-token.c index eb43f35fe..de669b8e9 100644 --- a/src/restore-token.c +++ b/src/restore-token.c @@ -250,7 +250,7 @@ xdp_session_persistence_replace_restore_token_with_data (Session *session, g_clear_pointer (&value, g_variant_unref); } - *in_out_options = g_variant_builder_end (&options_builder); + *in_out_options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); } void @@ -376,5 +376,5 @@ xdp_session_persistence_replace_restore_data_with_token (Session *session, *in_out_persist_mode = PERSIST_MODE_NONE; } - *in_out_results = g_variant_builder_end (&results_builder); + *in_out_results = g_variant_ref_sink (g_variant_builder_end (&results_builder)); } diff --git a/src/screen-cast.c b/src/screen-cast.c index bb115aa3c..3561aec54 100644 --- a/src/screen-cast.c +++ b/src/screen-cast.c @@ -227,7 +227,7 @@ handle_create_session (XdpDbusScreenCast *object, g_autoptr(XdpDbusImplRequest) impl_request = NULL; Session *session; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; REQUEST_AUTOLOCK (request); @@ -254,7 +254,7 @@ handle_create_session (XdpDbusScreenCast *object, } g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT); - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); g_object_set_qdata_full (G_OBJECT (request), quark_request_session, @@ -486,7 +486,7 @@ handle_select_sources (XdpDbusScreenCast *object, g_autoptr(GError) error = NULL; g_autoptr(XdpDbusImplRequest) impl_request = NULL; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; REQUEST_AUTOLOCK (request); @@ -580,7 +580,7 @@ handle_select_sources (XdpDbusScreenCast *object, return G_DBUS_METHOD_INVOCATION_HANDLED; } - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); /* If 'restore_token' is passed, lookup the corresponding data in the * permission store and / or the GHashTable with transient permissions. @@ -771,7 +771,7 @@ start_done (GObject *source_object, ScreenCastSession *screen_cast_session; guint response = 2; gboolean should_close_session; - GVariant *results = NULL; + g_autoptr(GVariant) results = NULL; g_autoptr(GError) error = NULL; REQUEST_AUTOLOCK (request); @@ -788,6 +788,7 @@ start_done (GObject *source_object, { g_dbus_error_strip_remote_error (error); g_warning ("A backend call failed: %s", error->message); + g_clear_error (&error); } should_close_session = !request->exported || response != 0; @@ -813,7 +814,7 @@ start_done (GObject *source_object, GVariantBuilder results_builder; g_variant_builder_init (&results_builder, G_VARIANT_TYPE_VARDICT); - results = g_variant_builder_end (&results_builder); + results = g_variant_ref_sink (g_variant_builder_end (&results_builder)); } xdp_dbus_request_emit_response (XDP_DBUS_REQUEST (request), response, results); @@ -846,7 +847,7 @@ handle_start (XdpDbusScreenCast *object, g_autoptr(GError) error = NULL; g_autoptr(XdpDbusImplRequest) impl_request = NULL; GVariantBuilder options_builder; - GVariant *options; + g_autoptr(GVariant) options = NULL; REQUEST_AUTOLOCK (request); @@ -908,7 +909,7 @@ handle_start (XdpDbusScreenCast *object, request_export (request, g_dbus_method_invocation_get_connection (invocation)); g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT); - options = g_variant_builder_end (&options_builder); + options = g_variant_ref_sink (g_variant_builder_end (&options_builder)); g_object_set_qdata_full (G_OBJECT (request), quark_request_session,