[folks] Bug 647562 — Don't crash on duplicate group channels



commit 0517262c104a2c30c621ab180f1b4ac6e2b47b13
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Tue Apr 12 16:08:40 2011 +0100

    Bug 647562 â?? Don't crash on duplicate group channels

 NEWS                                          |    1 +
 backends/telepathy/lib/tpf-persona-store.vala |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index fe372a6..14a31cd 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Overview of changes from libfolks 0.5.0 to libfolks 0.5.1
 
 Bugs fixed:
 * Bug 645388 â?? Group channels are leaked
+* Bug 647562 â?? Don't crash on duplicate group channels
 
 Overview of changes from libfolks 0.4.0 to libfolks 0.5.0
 =========================================================
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index c537fdc..c174b44 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -1109,6 +1109,23 @@ public class Tpf.PersonaStore : Folks.PersonaStore
           var c = (Channel) s;
           var name = c.get_identifier ();
 
+          var existing_channel = this._groups[name];
+          if (existing_channel != null)
+            {
+              /* Somehow, this group channel has already been set up. We have to
+               * hold a reference to the existing group while unsetting it in
+               * the group map so that unsetting it doesn't cause it to be
+               * destroyed. If that were to happen, channel_invalidated_cb()
+               * would remove it from the group map a second time, causing a
+               * double unref. */
+              existing_channel.ref ();
+              this._groups.unset (name);
+              existing_channel.unref ();
+            }
+
+          /* Drop all references before we set the new channel */
+          existing_channel = null;
+
           this._groups[name] = c;
           this._group_channels_unready.unset (name);
 



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