]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't crash on a guest directmedia call
authorTerry Wilson <twilson@digium.com>
Fri, 22 Jun 2012 20:05:22 +0000 (20:05 +0000)
committerTerry Wilson <twilson@digium.com>
Fri, 22 Jun 2012 20:05:22 +0000 (20:05 +0000)
A sip_pvt may not have relatedpeer set if a call doesn't match up
with a peer. If there is no relatedpeer, there is no direct media
ACL to apply, so just return that it is allowed.

(closes issue ASTERISK-20040)
Reported by: Terry Wilson
........

Merged revisions 369214 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 369215 from http://svn.asterisk.org/svn/asterisk/branches/10

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369217 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index fa889d86da09b857b63d956f5da3a65e7bbf2f3b..540dae1d54ad5f3747a1ec1fc71b86fc6e2eeb24 100644 (file)
@@ -30842,17 +30842,17 @@ static int sip_allow_anyrtp_remote(struct ast_channel *chan1, struct ast_channel
        }
 
        sip_pvt_lock(p2);
-       if (p2->relatedpeer->directmediaha) {
+       if (p2->relatedpeer && p2->relatedpeer->directmediaha) {
                p2_directmediaha = ast_duplicate_ha_list(p2->relatedpeer->directmediaha);
        }
        sip_pvt_unlock(p2);
 
        sip_pvt_lock(p1);
-       if (p1->relatedpeer->directmediaha) {
+       if (p1->relatedpeer && p1->relatedpeer->directmediaha) {
                p1_directmediaha = ast_duplicate_ha_list(p1->relatedpeer->directmediaha);
        }
 
-       if (ast_test_flag(&p1->flags[0], SIP_DIRECT_MEDIA)) {
+       if (p2_directmediaha && ast_test_flag(&p1->flags[0], SIP_DIRECT_MEDIA)) {
                if (!apply_directmedia_ha(p1, p2_directmediaha, rtptype)) {
                        res = 0;
                }
@@ -30864,7 +30864,7 @@ static int sip_allow_anyrtp_remote(struct ast_channel *chan1, struct ast_channel
        }
 
        sip_pvt_lock(p2);
-       if (ast_test_flag(&p2->flags[0], SIP_DIRECT_MEDIA)) {
+       if (p1_directmediaha && ast_test_flag(&p2->flags[0], SIP_DIRECT_MEDIA)) {
                if (!apply_directmedia_ha(p2, p1_directmediaha, rtptype)) {
                        res = 0;
                }