protect agent_bridgedchannel() from segfaulting when there is no bridged channel (issue #5879)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@7271 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2005-12-02 00:28:48 +00:00
parent fb8d0a544d
commit 41023ecb9c

View File

@@ -910,15 +910,16 @@ static int agent_ack_sleep( void *data )
static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge) 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; struct ast_channel *ret=NULL;
if (p) {
p = bridge->tech_pvt;
if (chan == p->chan) if (chan == p->chan)
ret = bridge->_bridge; ret = bridge->_bridge;
else if (chan == bridge->_bridge) else if (chan == bridge->_bridge)
ret = p->chan; ret = p->chan;
}
if (option_debug) 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>"); ast_log(LOG_DEBUG, "Asked for bridged channel on '%s'/'%s', returning '%s'\n", chan->name, bridge->name, ret ? ret->name : "<none>");
return ret; return ret;