From ce4a27e1fe84ffa156c4132e6d6766893f2cb200 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Sat, 13 Jun 2026 15:40:17 +0200 Subject: [PATCH] portal: Check if the monitor is closed before emitting progress `emit_progress` is called from a thread while another thread could unexport/close the GDbusInterfaceSkeleton. If that happens, the connection becomes NULL which is illegal for `g_dbus_connection_emit_signal` which results in dereferencing an unset error. The fix is to lock the UpdateMonitorData, and then only emit the signal if it is not closed. --- portal/flatpak-portal.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/portal/flatpak-portal.c b/portal/flatpak-portal.c index e06783f80..f9304464a 100644 --- a/portal/flatpak-portal.c +++ b/portal/flatpak-portal.c @@ -2357,7 +2357,6 @@ emit_progress (PortalFlatpakUpdateMonitor *monitor, const char *error_message) { UpdateMonitorData *m = update_monitor_get_data (monitor); - GDBusConnection *connection; GVariantBuilder builder; g_autoptr(GError) error = NULL; @@ -2379,8 +2378,10 @@ emit_progress (PortalFlatpakUpdateMonitor *monitor, g_variant_builder_add (&builder, "{sv}", "error_message", g_variant_new_string (error_message)); } - connection = update_monitor_get_connection (monitor); - if (!g_dbus_connection_emit_signal (connection, + g_mutex_lock (&m->lock); + + if (!m->closed && + !g_dbus_connection_emit_signal (update_monitor_get_connection (monitor), m->sender, m->obj_path, FLATPAK_PORTAL_INTERFACE_UPDATE_MONITOR, @@ -2390,6 +2391,8 @@ emit_progress (PortalFlatpakUpdateMonitor *monitor, { g_warning ("Failed to emit ::progress: %s", error->message); } + + g_mutex_unlock (&m->lock); } static char *