res_pjsip_session.c: Fix crashes seen when call cancelled.
authorRichard Mudgett <rmudgett@digium.com>
Thu, 30 Jul 2015 22:05:57 +0000 (17:05 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Thu, 30 Jul 2015 22:05:57 +0000 (17:05 -0500)
Two testsuite tests crashed in the same place as a result of an INVITE
being CANCELed.

tests/channels/pjsip/resolver/srv/failover/in_dialog/transport_unspecified
tests/channels/pjsip/resolver/srv/failover/in_dialog/transport_tcp

The session pointer is no longer in the inv->mod_data[session_module.id]
location because the INVITE transaction has reached the terminated state.

ASTERISK-25297 #close
Reported by: Richard Mudgett

Change-Id: Idb75fdca0321f5447d5dac737a632a5f03614427

res/res_pjsip_session.c

index 4544671..625ab8b 100644 (file)
@@ -2713,8 +2713,10 @@ static void session_inv_on_media_update(pjsip_inv_session *inv, pj_status_t stat
        struct ast_sip_session *session = inv->mod_data[session_module.id];
        const pjmedia_sdp_session *local, *remote;
 
-       if (!session->channel) {
-               /* If we don't have a channel. We really don't care about media updates.
+       if (!session || !session->channel) {
+               /*
+                * If we don't have a session or channel then we really
+                * don't care about media updates.
                 * Just ignore
                 */
                return;