[telepathy-gabble/master] Don't rely on a side-effect of g_assert()

Will Thompson will.thompson at collabora.co.uk
Thu Sep 10 08:10:41 PDT 2009


Simon pointed out that this is a bad idea: if it's optimized out, then
resource will be uninitialized!
---
 src/presence-cache.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/presence-cache.c b/src/presence-cache.c
index 382a574..2d9e80f 100644
--- a/src/presence-cache.c
+++ b/src/presence-cache.c
@@ -1034,6 +1034,7 @@ _caps_disco_cb (GabbleDisco *disco,
   gboolean bad_hash = FALSE;
   TpBaseConnection *base_conn;
   gchar *resource;
+  gboolean jid_is_valid;
 
   cache = GABBLE_PRESENCE_CACHE (user_data);
   priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
@@ -1067,7 +1068,8 @@ _caps_disco_cb (GabbleDisco *disco,
     }
 
   /* If tp_handle_ensure () was happy with the jid, it's valid. */
-  g_assert (gabble_decode_jid (jid, NULL, NULL, &resource));
+  jid_is_valid = gabble_decode_jid (jid, NULL, NULL, &resource);
+  g_assert (jid_is_valid);
   waiter_self = find_matching_waiter (waiters, handle, resource);
   g_free (resource);
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list