From c7c0664bc4554efd21d491e2d4e09c66c9a9bae1 Mon Sep 17 00:00:00 2001
From: Alec L Davis <sivad.a@paradise.net.nz>
Date: Fri, 11 Mar 2011 06:56:06 +0000
Subject: [PATCH] Merged revisions 310287 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r310287 | alecdavis | 2011-03-11 19:47:44 +1300 (Fri, 11 Mar 2011) | 17 lines

  remote_bridge_loop: prevent segfault when after transfer of IAX2 of DAHDI call

  If the channel condition is one of the following after breaking out of the loop, don't try to update_peer
  (where x = 0/1)
   1). ZOMBIE
   2). cx->tech_pvt != pvtx
   3). gluex != ast_rtp_instance_get_glue(cx->tech->type))

  (closes issue #18781)
  Reported by: alecdavis
  Patches:
        bug18781.diff3.txt uploaded by alecdavis (license 585)
  Tested by: alecdavis, ZX81

  Review: https://reviewboard.asterisk.org/r/1128/
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@310288 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 main/rtp_engine.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index b2543893af..b79ef0bbb4 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -1234,10 +1234,22 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
 		cs[1] = cs[2];
 	}
 
-	if (glue0->update_peer(c0, NULL, NULL, NULL, 0, 0)) {
+	if (ast_test_flag(c0, AST_FLAG_ZOMBIE)) {
+		ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", c0->name);
+	} else if (c0->tech_pvt != pvt0) {
+		ast_debug(1, "Channel c0->'%s' pvt changed, in bridge with c1->'%s'\n", c0->name, c1->name);
+	} else if (glue0 != ast_rtp_instance_get_glue(c0->tech->type)) {
+		ast_debug(1, "Channel c0->'%s' technology changed, in bridge with c1->'%s'\n", c0->name, c1->name);
+	} else if (glue0->update_peer(c0, NULL, NULL, NULL, 0, 0)) {
 		ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c0->name);
 	}
-	if (glue1->update_peer(c1, NULL, NULL, NULL, 0, 0)) {
+	if (ast_test_flag(c1, AST_FLAG_ZOMBIE)) {
+		ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", c1->name);
+	} else if (c1->tech_pvt != pvt1) {
+		ast_debug(1, "Channel c1->'%s' pvt changed, in bridge with c0->'%s'\n", c1->name, c0->name);
+	} else if (glue1 != ast_rtp_instance_get_glue(c1->tech->type)) {
+		ast_debug(1, "Channel c1->'%s' technology changed, in bridge with c0->'%s'\n", c1->name, c0->name);
+	} else if (glue1->update_peer(c1, NULL, NULL, NULL, 0, 0)) {
 		ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c1->name);
 	}
 
-- 
GitLab