diff options
author | Malcolm Davenport <malcolmd@digium.com> | 2004-01-09 05:13:50 +0000 |
---|---|---|
committer | Malcolm Davenport <malcolmd@digium.com> | 2004-01-09 05:13:50 +0000 |
commit | d86261dc2b44fac06a1a09e9be714b349b468a68 (patch) | |
tree | f6873d3e0c5d2ee8688e367cc85cfd8a945a8cbe /channels | |
parent | 0448f34affa87189d6007474cb2556049f602262 (diff) |
Bug #736: Better checking to avoid chan_zap segfault re: ss_thread and zt_new()
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1907 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rwxr-xr-x | channels/chan_zap.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c index fc6491172..24c2bddef 100755 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -3050,11 +3050,13 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast) if (res) ast_log(LOG_WARNING, "Unable to start dial recall tone on channel %d\n", p->channel); p->owner = chan; - if (pthread_create(&threadid, &attr, ss_thread, chan)) { + if (chan && pthread_create(&threadid, &attr, ss_thread, chan)) { ast_log(LOG_WARNING, "Unable to start simple switch on channel %d\n", p->channel); res = tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_CONGESTION); zt_enable_ec(p); ast_hangup(chan); + } else if (!chan) { + ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", p->channel); } else { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Started three way call on channel %d\n", p->channel); @@ -4675,12 +4677,14 @@ static int handle_init_event(struct zt_pvt *i, int event) case SIG_SF: /* Check for callerid, digits, etc */ chan = zt_new(i, AST_STATE_RING, 0, SUB_REAL, 0, 0); - if (pthread_create(&threadid, &attr, ss_thread, chan)) { + if (chan && pthread_create(&threadid, &attr, ss_thread, chan)) { ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel); res = tone_zone_play_tone(i->subs[SUB_REAL].zfd, ZT_TONE_CONGESTION); if (res < 0) ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel); ast_hangup(chan); + } else if (!chan) { + ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel); } #if 0 printf("Created thread %ld detached in switch(2)\n", threadid); |