From 0f6713fcb9c70c86944dea684eaf1dcb6904d717 Mon Sep 17 00:00:00 2001 From: Conn O'Griofa Date: Tue, 10 Mar 2026 16:22:27 +0000 Subject: [PATCH] fix(linux/xdgportal): descriptor/pointer cleanups * Use g_clear_object to avoid dangling pointers during dbus teardown * Use g_autoptr to cleanup descriptor pointers on teardown * Use g_variant_ref_sink to keep correct floating reference ownership --- src/platform/linux/portalgrab.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/platform/linux/portalgrab.cpp b/src/platform/linux/portalgrab.cpp index 9c5ed398041..8ed34f9c0c6 100644 --- a/src/platform/linux/portalgrab.cpp +++ b/src/platform/linux/portalgrab.cpp @@ -194,13 +194,13 @@ namespace portal { } if (screencast_proxy) { - g_object_unref(screencast_proxy); + g_clear_object(&screencast_proxy); } if (remote_desktop_proxy) { - g_object_unref(remote_desktop_proxy); + g_clear_object(&remote_desktop_proxy); } if (conn) { - g_object_unref(conn); + g_clear_object(&conn); } } @@ -531,8 +531,8 @@ namespace portal { } int open_pipewire_remote(const gchar *session_path, int &fd) { - GUnixFDList *fd_list; - GVariant *msg = g_variant_new("(oa{sv})", session_path, nullptr); + g_autoptr(GUnixFDList) fd_list = nullptr; + g_autoptr(GVariant) msg = g_variant_ref_sink(g_variant_new("(oa{sv})", session_path, nullptr)); g_autoptr(GError) err = nullptr; g_autoptr(GVariant) reply = g_dbus_proxy_call_with_unix_fd_list_sync(screencast_proxy, "OpenPipeWireRemote", msg, G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &fd_list, nullptr, &err);