[asterisk-commits] branch 1.2 - r7271 /branches/1.2/channels/chan_agent.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Dec 1 18:28:49 CST 2005


Author: kpfleming
Date: Thu Dec  1 18:28:48 2005
New Revision: 7271

URL: http://svn.digium.com/view/asterisk?rev=7271&view=rev
Log:
protect agent_bridgedchannel() from segfaulting when there is no bridged channel (issue #5879)

Modified:
    branches/1.2/channels/chan_agent.c

Modified: branches/1.2/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_agent.c?rev=7271&r1=7270&r2=7271&view=diff
==============================================================================
--- branches/1.2/channels/chan_agent.c (original)
+++ branches/1.2/channels/chan_agent.c Thu Dec  1 18:28:48 2005
@@ -910,15 +910,16 @@
 
 static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge)
 {
-	struct agent_pvt *p;
+	struct agent_pvt *p = bridge->tech_pvt;
 	struct ast_channel *ret=NULL;
-	
-
-	p = bridge->tech_pvt;
-	if (chan == p->chan)
-		ret = bridge->_bridge;
-	else if (chan == bridge->_bridge)
-		ret = p->chan;
+
+	if (p) {
+		if (chan == p->chan)
+			ret = bridge->_bridge;
+		else if (chan == bridge->_bridge)
+			ret = p->chan;
+	}
+
 	if (option_debug)
 		ast_log(LOG_DEBUG, "Asked for bridged channel on '%s'/'%s', returning '%s'\n", chan->name, bridge->name, ret ? ret->name : "<none>");
 	return ret;



More information about the asterisk-commits mailing list