diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
index 840a030..4972ec7 100644
--- a/daemon/gdm-server.c
+++ b/daemon/gdm-server.c
@@ -502,7 +502,8 @@ get_server_environment (GdmServer *server)
         for (l = environ; *l != NULL; l++) {
                 char **str;
                 str = g_strsplit (*l, "=", 2);
-                g_hash_table_insert (hash, str[0], str[1]);
+                g_hash_table_insert (hash, g_strdup (str[0]), g_strdup (str[1]));
+                g_strfreev (str);
         }
 
         /* modify environment here */
@@ -953,6 +954,29 @@ gdm_server_finalize (GObject *object)
 
         gdm_server_stop (server);
 
+        if (server->priv->command)
+                g_free (server->priv->command);
+        if (server->priv->user_name)
+                g_free (server->priv->user_name);
+        if (server->priv->session_args)
+                g_free (server->priv->session_args);
+
+        if (server->priv->log_dir)
+                g_free (server->priv->log_dir);
+        if (server->priv->display_name)
+        g_free (server->priv->display_name);
+        if (server->priv->display_device)
+                g_free (server->priv->display_device);
+        if (server->priv->auth_file)
+                g_free (server->priv->auth_file);
+
+        if (server->priv->parent_display_name)
+                g_free (server->priv->parent_display_name);
+        if (server->priv->parent_auth_file)
+                g_free (server->priv->parent_auth_file);
+        if (server->priv->chosen_hostname)
+                g_free (server->priv->chosen_hostname);
+
         G_OBJECT_CLASS (gdm_server_parent_class)->finalize (object);
 }
 
