summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-06-14 14:11:54 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-06-14 16:02:21 +0100
commit4c7b4facf385df1ac4a268962b6ab0fb23fcd76d (patch)
tree6f6e5dd522f70f7c726b26c50132f30c8aae9417
parentf65b6723c26dac11e320ac380ce3aec0fb2e71be (diff)
tp_connection_get_detailed_error: fix a memory leak
If we were invalidated without a detailed error, we'd assign a new empty hash table to a const out parameter, leaking it. Instead, keep creating the empty hash table lazily, but stash it in priv so it will be freed in our destructor.
-rw-r--r--telepathy-glib/connection.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c
index 244fe1412..1a0fea45b 100644
--- a/telepathy-glib/connection.c
+++ b/telepathy-glib/connection.c
@@ -881,8 +881,6 @@ tp_connection_status_changed_cb (TpConnection *self,
if (self->priv->connection_error == NULL)
{
- g_assert (self->priv->connection_error_details == NULL);
-
tp_connection_status_reason_to_gerror (reason, prev_status, &error);
}
else
@@ -2249,7 +2247,16 @@ tp_connection_get_detailed_error (TpConnection *self,
* on the invalidation reason, and don't give any details */
if (details != NULL)
- *details = tp_asv_new (NULL, NULL);
+ {
+ if (self->priv->connection_error_details == NULL)
+ self->priv->connection_error_details = g_hash_table_new (
+ g_str_hash, g_str_equal);
+
+ g_assert (g_hash_table_size (self->priv->connection_error_details)
+ == 0);
+
+ *details = self->priv->connection_error_details;
+ }
if (proxy->invalidated->domain == TP_ERRORS)
{