[telepathy-gabble/master] Don't assume session is non-NULL in GetCallState

Will Thompson will.thompson at collabora.co.uk
Fri May 29 10:15:11 PDT 2009


If GetCallState() is called before RequestStreams() and friends,
there'll be no JingleSession for the channel, so we need to check if it
exists yet before dereferencing it.

It's valid to omit participants whose call state is 0, and if there's no
session we might not know who the peer is yet anyway (if the
RequestChannel(0) calling convention's in use).

Reviewed-by: Sjoerd Simons <sjoerd.simons at collabora.co.uk>
---
 src/media-channel-hold.c           |    5 +++--
 tests/twisted/jingle/call-state.py |    4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/media-channel-hold.c b/src/media-channel-hold.c
index e7ee621..f88e6fd 100644
--- a/src/media-channel-hold.c
+++ b/src/media-channel-hold.c
@@ -324,8 +324,9 @@ gabble_media_channel_get_call_states (TpSvcChannelInterfaceCallState *iface,
   GabbleMediaChannel *self = (GabbleMediaChannel *) iface;
   GHashTable *states = g_hash_table_new (g_direct_hash, g_direct_equal);
 
-  g_hash_table_insert (states, GUINT_TO_POINTER (self->priv->session->peer),
-      GUINT_TO_POINTER (self->priv->call_state));
+  if (self->priv->session != NULL)
+    g_hash_table_insert (states, GUINT_TO_POINTER (self->priv->session->peer),
+        GUINT_TO_POINTER (self->priv->call_state));
 
   tp_svc_channel_interface_call_state_return_from_get_call_states (context,
       states);
diff --git a/tests/twisted/jingle/call-state.py b/tests/twisted/jingle/call-state.py
index e692b46..d165236 100644
--- a/tests/twisted/jingle/call-state.py
+++ b/tests/twisted/jingle/call-state.py
@@ -31,6 +31,10 @@ def test(jp, q, bus, conn, stream):
     assert cs.CHANNEL_IFACE_CALL_STATE in chan_props['Interfaces'], \
         chan_props['Interfaces']
 
+    call_states = chan.CallState.GetCallStates()
+    assert call_states == { handle: 0 } or \
+        call_states == {}, call_states
+
     chan.StreamedMedia.RequestStreams(handle, [cs.MEDIA_STREAM_TYPE_AUDIO])
 
     # S-E gets notified about new session handler, and calls Ready on it
-- 
1.5.6.5



More information about the telepathy-commits mailing list