[telepathy-mission-control/master] McdAccountManager: make sure write_conf_id gets cancelled during teardown

Simon McVittie simon.mcvittie at collabora.co.uk
Wed May 27 05:18:45 PDT 2009


Previously this was a use-after-free: the configuration is forced to be
written during finalize, then GKeyFile is freed, then the timer goes off
later and the freed GKeyFile is used again.
---
 src/mcd-account-manager.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c
index a599056..fdec336 100644
--- a/src/mcd-account-manager.c
+++ b/src/mcd-account-manager.c
@@ -758,6 +758,7 @@ write_conf (gpointer userdata)
     gsize len;
 
     DEBUG ("called");
+    g_source_remove (write_conf_id);
     write_conf_id = 0;
 
     data = g_key_file_to_data (keyfile, &len, &error);
@@ -925,7 +926,10 @@ _mcd_account_manager_finalize (GObject *object)
     McdAccountManagerPrivate *priv = MCD_ACCOUNT_MANAGER_PRIV (object);
 
     if (write_conf_id)
-	write_conf (priv->keyfile);
+    {
+        write_conf (priv->keyfile);
+        g_assert (write_conf_id == 0);
+    }
     g_key_file_free (priv->keyfile);
 
     g_free (priv->account_connections_dir);
-- 
1.5.6.5




More information about the telepathy-commits mailing list