freetdm: fixing more potential null pointers in native bridge mode.

This commit is contained in:
James Zhang 2012-03-27 18:00:24 -04:00
parent bfefbb5522
commit a2db3c24b3
2 changed files with 42 additions and 29 deletions

View File

@ -426,9 +426,15 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj)
/* note that the channels being dequeued here may not belong to this span /* note that the channels being dequeued here may not belong to this span
they may belong to just about any other span that one of our channels they may belong to just about any other span that one of our channels
happens to be bridged to */ happens to be bridged to */
sngss7_chan_data_t *peer_info = peerchan->call_data; sngss7_chan_data_t *peer_info;
sngss7_chan_data_t *chan_info = peer_info->peer_data; sngss7_chan_data_t *chan_info;
peer_info = peerchan->call_data;
if (peer_info) {
chan_info = peer_info->peer_data;
if (chan_info) {
ftdmchan = chan_info->ftdmchan; ftdmchan = chan_info->ftdmchan;
if (ftdmchan) {
/* /*
if there is any state changes at all, those will be done in the opposite channel if there is any state changes at all, those will be done in the opposite channel
@ -445,6 +451,9 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj)
ftdm_channel_unlock(ftdmchan); ftdm_channel_unlock(ftdmchan);
} }
}
}
}
/* clean out all pending stack events */ /* clean out all pending stack events */
while ((sngss7_event = ftdm_queue_dequeue(sngss7_span->event_queue))) { while ((sngss7_event = ftdm_queue_dequeue(sngss7_span->event_queue))) {
@ -1519,11 +1528,13 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan)
*/ */
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
sngss7_chan_data_t *peer_info = sngss7_info->peer_data; sngss7_chan_data_t *peer_info = sngss7_info->peer_data;
if (peer_info) {
sngss7_info->peer_data = NULL; sngss7_info->peer_data = NULL;
if (peer_info) { if (peer_info) {
peer_info->peer_data = NULL; peer_info->peer_data = NULL;
} }
} }
}
/* close the channel */ /* close the channel */
SS7_DEBUG_CHAN(ftdmchan,"FTDM Channel Close %s\n", ""); SS7_DEBUG_CHAN(ftdmchan,"FTDM Channel Close %s\n", "");

View File

@ -72,6 +72,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
var, peer_span->signal_type); var, peer_span->signal_type);
} else { } else {
peer_info = peer_chan->call_data; peer_info = peer_chan->call_data;
if (peer_info) {
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Starting native bridge with peer CIC %d\n", SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Starting native bridge with peer CIC %d\n",
sngss7_info->circuit->cic, peer_info->circuit->cic); sngss7_info->circuit->cic, peer_info->circuit->cic);
@ -90,6 +91,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
} }
} }
} }
}
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE) && sngss7_info->peer_data) { if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE) && sngss7_info->peer_data) {
sngss7_span_data_t *span_data = ftdmchan->span->signal_data; sngss7_span_data_t *span_data = ftdmchan->span->signal_data;