diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c
index 7d5b560..a11f759 100644
--- a/daemon/gdm-session-direct.c
+++ b/daemon/gdm-session-direct.c
@@ -516,6 +516,7 @@ get_session_command_for_file (const char *file,
                                          &full_path,
                                          G_KEY_FILE_NONE,
                                          &error);
+        g_free (full_path);
         if (! res) {
                 g_debug ("GdmSessionDirect: File '%s' not found: %s", file, error->message);
                 g_error_free (error);
@@ -712,11 +713,11 @@ get_fallback_session_name (void)
         return name;
 }
 
-static const char *
+static char *
 get_default_session_name (GdmSessionDirect *session)
 {
         if (session->priv->saved_session != NULL) {
-                return session->priv->saved_session;
+                return g_strdup (session->priv->saved_session);
         }
 
         return get_fallback_session_name ();
@@ -725,12 +726,15 @@ get_default_session_name (GdmSessionDirect *session)
 static void
 gdm_session_direct_defaults_changed (GdmSessionDirect *session)
 {
+        char *session_name;
+
         _gdm_session_default_language_name_changed (GDM_SESSION (session),
                                                     get_default_language_name (session));
         _gdm_session_default_layout_name_changed (GDM_SESSION (session),
                                                   get_default_layout_name (session));
-        _gdm_session_default_session_name_changed (GDM_SESSION (session),
-                                                   get_default_session_name (session));
+        session_name = get_default_session_name (session);
+        _gdm_session_default_session_name_changed (GDM_SESSION (session), session_name);
+        g_free (session_name);
 }
 
 static void
@@ -778,7 +782,7 @@ gdm_session_direct_handle_username_changed (GdmSessionDirect *session,
                  session->priv->selected_user != NULL ? session->priv->selected_user : "<unset>",
                  (strlen (text)) ? text : "<unset>");
 
-        gdm_session_direct_select_user (GDM_SESSION (session), (strlen (text) > 0) ? g_strdup (text) : NULL);
+        gdm_session_direct_select_user (GDM_SESSION (session), (strlen (text) > 0) ? text : NULL);
 
         _gdm_session_selected_user_changed (GDM_SESSION (session), session->priv->selected_user);
 
@@ -1198,6 +1202,7 @@ gdm_session_direct_handle_saved_session_name_read (GdmSessionDirect *session,
         DBusMessage *reply;
         DBusError    error;
         const char  *session_name;
+        char        *default_name;
 
         dbus_error_init (&error);
         if (! dbus_message_get_args (message, &error,
@@ -1218,14 +1223,15 @@ gdm_session_direct_handle_saved_session_name_read (GdmSessionDirect *session,
                 goto out;
         }
 
-        if (strcmp (session_name,
-                    get_default_session_name (session)) != 0) {
+        default_name = get_default_session_name (session);
+        if (strcmp (session_name, default_name) != 0) {
                 g_free (session->priv->saved_session);
                 session->priv->saved_session = g_strdup (session_name);
 
                 _gdm_session_default_session_name_changed (GDM_SESSION (session),
                                                            session_name);
         }
+        g_free (default_name);
  out:
         return DBUS_HANDLER_RESULT_HANDLED;
 }
@@ -1981,13 +1987,13 @@ get_layout_name (GdmSessionDirect *session)
         return get_default_layout_name (session);
 }
 
-static const char *
+static char *
 get_session_name (GdmSessionDirect *session)
 {
         /* FIXME: test the session names before we use them? */
 
         if (session->priv->selected_session != NULL) {
-                return session->priv->selected_session;
+                return g_strdup (session->priv->selected_session);
         }
 
         return get_default_session_name (session);
@@ -1999,8 +2005,11 @@ get_session_command (GdmSessionDirect *session)
         gboolean res;
         char    *command;
         char    *filename;
+        char    *session_name;
 
-        filename = g_strdup_printf ("%s.desktop", get_session_name (session));
+        session_name = get_session_name (session);
+        filename = g_strdup_printf ("%s.desktop", session_name);
+        g_free (session_name);
 
         command = NULL;
         res = get_session_command_for_file (filename, &command);
@@ -2032,12 +2041,16 @@ gdm_session_direct_set_environment_variable (GdmSessionDirect *session,
 static void
 setup_session_environment (GdmSessionDirect *session)
 {
+        char    *session_name;
+
+        session_name = get_session_name (session);
         gdm_session_direct_set_environment_variable (session,
                                                      "GDMSESSION",
-                                                     get_session_name (session));
+                                                     session_name);
         gdm_session_direct_set_environment_variable (session,
                                                      "DESKTOP_SESSION",
-                                                     get_session_name (session));
+                                                     session_name);
+        g_free (session_name);
 
         gdm_session_direct_set_environment_variable (session,
                                                      "LANG",
@@ -2207,11 +2220,14 @@ gdm_session_direct_bypasses_xsession (GdmSessionDirect *session_direct)
         gboolean    bypasses_xsession = FALSE;
         char       *filename;
         char       *full_path;
+        char       *session_name;
 
         g_return_val_if_fail (session_direct != NULL, FALSE);
         g_return_val_if_fail (GDM_IS_SESSION_DIRECT (session_direct), FALSE);
 
-        filename = g_strdup_printf ("%s.desktop", get_session_name (session_direct));
+        session_name = get_session_name (session_direct);
+        filename = g_strdup_printf ("%s.desktop", session_name);
+        g_free (session_name);
 
         key_file = g_key_file_new ();
         error = NULL;
@@ -2221,6 +2237,7 @@ gdm_session_direct_bypasses_xsession (GdmSessionDirect *session_direct)
                                          &full_path,
                                          G_KEY_FILE_NONE,
                                          &error);
+        g_free (full_path);
         if (! res) {
                 g_debug ("GdmSessionDirect: File '%s' not found: %s", filename, error->message);
                 goto out;
@@ -2251,6 +2268,8 @@ static void
 gdm_session_direct_select_session (GdmSession *session,
                                    const char *text)
 {
+        char *session_name;
+
         GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
 
         g_free (impl->priv->selected_session);
@@ -2261,8 +2280,9 @@ gdm_session_direct_select_session (GdmSession *session,
                 impl->priv->selected_session = g_strdup (text);
         }
 
-        send_dbus_string_signal (impl, "SetSessionName",
-                                 get_session_name (impl));
+        session_name = get_session_name (impl);
+        send_dbus_string_signal (impl, "SetSessionName", session_name);
+        g_free (session_name);
 }
 
 static void
