Blob Blame History Raw
From 7c9e236f9015aae2ea5868b67ff8036766cb7099 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 15 Sep 2020 11:28:48 -0400
Subject: [PATCH 3/3] xdmcp-display-factory: Clear launch environment when done
 with it

The XDMCP disply factory examines the sessions of its displays'
launch environments when the displays change status.

Unfortunately it leaks a reference to the launch environment when
doing that.

This commit fixes the reference leak which leads to an fd leak.
---
 daemon/gdm-xdmcp-display-factory.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/daemon/gdm-xdmcp-display-factory.c b/daemon/gdm-xdmcp-display-factory.c
index 2e14beab4..98232113f 100644
--- a/daemon/gdm-xdmcp-display-factory.c
+++ b/daemon/gdm-xdmcp-display-factory.c
@@ -2091,60 +2091,62 @@ on_display_status_changed (GdmDisplay             *display,
                 gdm_display_factory_queue_purge_displays (GDM_DISPLAY_FACTORY (factory));
                 break;
         case GDM_DISPLAY_FAILED:
                 gdm_display_factory_queue_purge_displays (GDM_DISPLAY_FACTORY (factory));
                 break;
         case GDM_DISPLAY_UNMANAGED:
                 if (session != NULL) {
                         g_signal_handlers_disconnect_by_func (G_OBJECT (session),
                                                               G_CALLBACK (on_client_disconnected),
                                                               display);
                 }
                 break;
         case GDM_DISPLAY_PREPARED:
                 break;
         case GDM_DISPLAY_MANAGED:
                 if (session != NULL) {
                         g_signal_connect_object (G_OBJECT (session),
                                                  "client-disconnected",
                                                  G_CALLBACK (on_client_disconnected),
                                                  display, G_CONNECT_SWAPPED);
                         g_signal_connect_object (G_OBJECT (session),
                                                  "disconnected",
                                                  G_CALLBACK (on_client_disconnected),
                                                  display, G_CONNECT_SWAPPED);
                 }
                 break;
         default:
                 g_assert_not_reached ();
                 break;
         }
+
+        g_clear_object (&launch_environment);
 }
 
 static GdmDisplay *
 gdm_xdmcp_display_create (GdmXdmcpDisplayFactory *factory,
                           const char             *hostname,
                           GdmAddress             *address,
                           int                     displaynum)
 {
         GdmDisplay      *display;
         GdmDisplayStore *store;
         gboolean         use_chooser;
 
         g_debug ("GdmXdmcpDisplayFactory: Creating xdmcp display for %s:%d",
                 hostname ? hostname : "(null)", displaynum);
 
         use_chooser = FALSE;
         if (factory->priv->honor_indirect) {
                 IndirectClient *ic;
 
                 ic = indirect_client_lookup (factory, address);
 
                 /* This was an indirect thingie and nothing was yet chosen,
                  * use a chooser */
                 if (ic != NULL && ic->chosen_address == NULL) {
                         use_chooser = TRUE;
                 }
         }
 
         if (use_chooser) {
                 display = gdm_xdmcp_chooser_display_new (hostname,
-- 
2.26.2