[gdm/gnome-2-30] Various memory leak fixes



commit 0a6c4f6225fea9346763113927db4ab90938d48d
Author: Wang Xin <jedy wang sun com>
Date:   Thu Jun 17 13:39:33 2010 -0400

    Various memory leak fixes
    
    https://bugzilla.gnome.org/show_bug.cgi?id=620430
    With help from Pablo Castellano

 daemon/gdm-product-display.c    |    2 ++
 daemon/gdm-product-slave.c      |    1 +
 daemon/gdm-server.c             |   12 ++++++++++++
 daemon/gdm-session-direct.c     |    7 ++-----
 daemon/gdm-session-worker-job.c |    3 +++
 daemon/gdm-session-worker.c     |   26 +++++++++++++-------------
 daemon/gdm-simple-slave.c       |   16 ++++++++++++----
 daemon/gdm-slave-proxy.c        |    1 +
 daemon/gdm-slave.c              |    1 +
 daemon/gdm-welcome-session.c    |   12 +++++++++++-
 10 files changed, 58 insertions(+), 23 deletions(-)
---
diff --git a/daemon/gdm-product-display.c b/daemon/gdm-product-display.c
index 5dbc4d1..9b68cb9 100644
--- a/daemon/gdm-product-display.c
+++ b/daemon/gdm-product-display.c
@@ -244,6 +244,8 @@ gdm_product_display_finalize (GObject *object)
 
         g_return_if_fail (product_display->priv != NULL);
 
+        g_free (product_display->priv->relay_address);
+
         G_OBJECT_CLASS (gdm_product_display_parent_class)->finalize (object);
 }
 
diff --git a/daemon/gdm-product-slave.c b/daemon/gdm-product-slave.c
index 5ecc1e9..d4611a9 100644
--- a/daemon/gdm-product-slave.c
+++ b/daemon/gdm-product-slave.c
@@ -854,6 +854,7 @@ create_new_session (GdmProductSlave *slave)
         g_free (display_id);
         g_free (display_name);
         g_free (display_hostname);
+        g_free (display_x11_authority_file);
         g_free (display_device);
 
         g_signal_connect (slave->priv->session,
diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
index e7560a3..c829199 100644
--- a/daemon/gdm-server.c
+++ b/daemon/gdm-server.c
@@ -512,6 +512,7 @@ get_server_environment (GdmServer *server)
                 char **str;
                 str = g_strsplit (*l, "=", 2);
                 g_hash_table_insert (hash, str[0], str[1]);
+                g_free (str);
         }
 
         /* modify environment here */
@@ -962,6 +963,17 @@ gdm_server_finalize (GObject *object)
 
         gdm_server_stop (server);
 
+        g_free (server->priv->command);
+        g_free (server->priv->user_name);
+        g_free (server->priv->session_args);
+        g_free (server->priv->log_dir);
+        g_free (server->priv->display_name);
+        g_free (server->priv->display_device);
+        g_free (server->priv->auth_file);
+        g_free (server->priv->parent_display_name);
+        g_free (server->priv->parent_auth_file);
+        g_free (server->priv->chosen_hostname);
+
         G_OBJECT_CLASS (gdm_server_parent_class)->finalize (object);
 }
 
diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c
index 031ae33..9ba2e6c 100644
--- a/daemon/gdm-session-direct.c
+++ b/daemon/gdm-session-direct.c
@@ -493,7 +493,6 @@ get_session_command_for_file (const char *file,
 {
         GKeyFile   *key_file;
         GError     *error;
-        char       *full_path;
         char       *exec;
         gboolean    ret;
         gboolean    res;
@@ -509,11 +508,10 @@ get_session_command_for_file (const char *file,
         g_debug ("GdmSessionDirect: looking for session file '%s'", file);
 
         error = NULL;
-        full_path = NULL;
         res = g_key_file_load_from_dirs (key_file,
                                          file,
                                          get_system_session_dirs (),
-                                         &full_path,
+                                         NULL,
                                          G_KEY_FILE_NONE,
                                          &error);
         if (! res) {
@@ -2186,7 +2184,6 @@ gdm_session_direct_bypasses_xsession (GdmSessionDirect *session_direct)
         gboolean    res;
         gboolean    bypasses_xsession = FALSE;
         char       *filename;
-        char       *full_path;
 
         g_return_val_if_fail (session_direct != NULL, FALSE);
         g_return_val_if_fail (GDM_IS_SESSION_DIRECT (session_direct), FALSE);
@@ -2198,7 +2195,7 @@ gdm_session_direct_bypasses_xsession (GdmSessionDirect *session_direct)
         res = g_key_file_load_from_dirs (key_file,
                                          filename,
                                          get_system_session_dirs (),
-                                         &full_path,
+                                         NULL,
                                          G_KEY_FILE_NONE,
                                          &error);
         if (! res) {
diff --git a/daemon/gdm-session-worker-job.c b/daemon/gdm-session-worker-job.c
index f359f4f..50bf4c0 100644
--- a/daemon/gdm-session-worker-job.c
+++ b/daemon/gdm-session-worker-job.c
@@ -446,6 +446,9 @@ gdm_session_worker_job_finalize (GObject *object)
 
         gdm_session_worker_job_stop (session_worker_job);
 
+        g_free (session_worker_job->priv->command);
+        g_free (session_worker_job->priv->server_address);
+
         G_OBJECT_CLASS (gdm_session_worker_job_parent_class)->finalize (object);
 }
 
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 5e34fb9..03a1d80 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -1652,6 +1652,9 @@ gdm_session_worker_accredit_user (GdmSessionWorker  *worker,
 
         ret = FALSE;
 
+        home = NULL;
+        shell = NULL;
+
         if (worker->priv->username == NULL) {
                 g_debug ("GdmSessionWorker: Username not set");
                 error_code = PAM_USER_UNKNOWN;
@@ -1662,8 +1665,6 @@ gdm_session_worker_accredit_user (GdmSessionWorker  *worker,
                 goto out;
         }
 
-        home = NULL;
-        shell = NULL;
         uid = 0;
         gid = 0;
         res = _lookup_passwd_info (worker->priv->username,
@@ -1722,6 +1723,8 @@ gdm_session_worker_accredit_user (GdmSessionWorker  *worker,
         ret = TRUE;
 
  out:
+        g_free (home);
+        g_free (shell);
         if (ret) {
                 g_debug ("GdmSessionWorker: state ACCREDITED");
                 ret = TRUE;
@@ -2970,19 +2973,16 @@ gdm_session_worker_finalize (GObject *object)
 
         gdm_session_worker_unwatch_child (worker);
 
-        if (worker->priv->username != NULL) {
-                g_free (worker->priv->username);
-                worker->priv->username = NULL;
-        }
-
-        if (worker->priv->arguments != NULL) {
-                g_strfreev (worker->priv->arguments);
-                worker->priv->arguments = NULL;
-        }
-
+        g_free (worker->priv->service);
+        g_free (worker->priv->x11_display_name);
+        g_free (worker->priv->x11_authority_file);
+        g_free (worker->priv->display_device);
+        g_free (worker->priv->hostname);
+        g_free (worker->priv->username);
+        g_free (worker->priv->server_address);
+        g_strfreev (worker->priv->arguments);
         if (worker->priv->environment != NULL) {
                 g_hash_table_destroy (worker->priv->environment);
-                worker->priv->environment = NULL;
         }
 
         G_OBJECT_CLASS (gdm_session_worker_parent_class)->finalize (object);
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index 3a47183..fb14223 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -110,7 +110,10 @@ on_session_started (GdmSession       *session,
 
         /* Run the PreSession script. gdmslave suspends until script has terminated */
         username = gdm_session_direct_get_username (slave->priv->session);
-        gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PreSession", username);
+        if (username != NULL) {
+                gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PreSession", username);
+        }
+        g_free (username);
 
         /* FIXME: should we do something here?
          * Note that error return status from PreSession script should
@@ -131,7 +134,10 @@ on_session_exited (GdmSession     *session,
 
         /* Run the PostSession script. gdmslave suspends until script has terminated */
         username = gdm_session_direct_get_username (slave->priv->session);
-        gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostSession", username);
+        if (username != NULL) {
+                gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostSession", username);
+        }
+        g_free (username);
 
         gdm_slave_stopped (GDM_SLAVE (slave));
 }
@@ -354,6 +360,7 @@ stop_greeter (GdmSimpleSlave *slave)
         if (username != NULL) {
                 gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostLogin", username);
         }
+        g_free (username);
 
         gdm_welcome_session_stop (GDM_WELCOME_SESSION (slave->priv->greeter));
         gdm_greeter_server_stop (slave->priv->greeter_server);
@@ -1003,8 +1010,6 @@ start_greeter (GdmSimpleSlave *slave)
 
         gdm_greeter_server_start (slave->priv->greeter_server);
 
-        address = gdm_greeter_server_get_address (slave->priv->greeter_server);
-
         g_debug ("GdmSimpleSlave: Creating greeter on %s %s %s", display_name, display_device, display_hostname);
         slave->priv->greeter = gdm_greeter_session_new (display_name,
                                                         display_device,
@@ -1029,7 +1034,10 @@ start_greeter (GdmSimpleSlave *slave)
         g_object_set (slave->priv->greeter,
                       "x11-authority-file", auth_file,
                       NULL);
+
+        address = gdm_greeter_server_get_address (slave->priv->greeter_server);
         gdm_welcome_session_set_server_address (GDM_WELCOME_SESSION (slave->priv->greeter), address);
+        g_free (address);
         gdm_welcome_session_start (GDM_WELCOME_SESSION (slave->priv->greeter));
 
         g_free (display_id);
diff --git a/daemon/gdm-slave-proxy.c b/daemon/gdm-slave-proxy.c
index d58d2c5..48efbd1 100644
--- a/daemon/gdm-slave-proxy.c
+++ b/daemon/gdm-slave-proxy.c
@@ -422,6 +422,7 @@ gdm_slave_proxy_finalize (GObject *object)
         g_return_if_fail (slave->priv != NULL);
 
         g_free (slave->priv->command);
+        g_free (slave->priv->log_path);
 
         G_OBJECT_CLASS (gdm_slave_proxy_parent_class)->finalize (object);
 }
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c
index 7e57f4f..a5cd809 100644
--- a/daemon/gdm-slave.c
+++ b/daemon/gdm-slave.c
@@ -332,6 +332,7 @@ gdm_slave_run_script (GdmSlave   *slave,
 
         g_ptr_array_foreach (env, (GFunc)g_free, NULL);
         g_ptr_array_free (env, TRUE);
+        g_strfreev (argv);
 
         if (! res) {
                 g_warning ("GdmSlave: Unable to run script: %s", error->message);
diff --git a/daemon/gdm-welcome-session.c b/daemon/gdm-welcome-session.c
index 0a6487a..c0842ac 100644
--- a/daemon/gdm-welcome-session.c
+++ b/daemon/gdm-welcome-session.c
@@ -767,7 +767,7 @@ parse_dbus_launch_output (const char *output,
         }
 
         if (addressp != NULL) {
-                *addressp = g_strdup (g_match_info_fetch (match_info, 1));
+                *addressp = g_match_info_fetch (match_info, 1);
         }
 
         if (pidp != NULL) {
@@ -804,6 +804,8 @@ start_dbus_daemon (GdmWelcomeSession *welcome_session)
 
         env = get_welcome_environment (welcome_session);
 
+        std_out = NULL;
+        std_err = NULL;
         error = NULL;
         res = spawn_command_line_sync_as_user (DBUS_LAUNCH_COMMAND,
                                                welcome_session->priv->user_name,
@@ -834,6 +836,8 @@ start_dbus_daemon (GdmWelcomeSession *welcome_session)
                 g_debug ("GdmWelcomeSession: Started D-Bus daemon on pid %d", welcome_session->priv->dbus_pid);
         }
  out:
+        g_free (std_out);
+        g_free (std_err);
         return res;
 }
 
@@ -1401,6 +1405,10 @@ gdm_welcome_session_finalize (GObject *object)
 
         gdm_welcome_session_stop (welcome_session);
 
+        if (welcome_session->priv->ckc != NULL) {
+                ck_connector_unref (welcome_session->priv->ckc);
+        }
+
         g_free (welcome_session->priv->command);
         g_free (welcome_session->priv->user_name);
         g_free (welcome_session->priv->group_name);
@@ -1412,6 +1420,8 @@ gdm_welcome_session_finalize (GObject *object)
         g_free (welcome_session->priv->server_address);
         g_free (welcome_session->priv->server_dbus_path);
         g_free (welcome_session->priv->server_dbus_interface);
+        g_free (welcome_session->priv->server_env_var_name);
+        g_free (welcome_session->priv->dbus_bus_address);
 
         G_OBJECT_CLASS (gdm_welcome_session_parent_class)->finalize (object);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]