[Asterisk-cvs] asterisk/channels chan_zap.c,1.159,1.160

malcolmd at lists.digium.com malcolmd at lists.digium.com
Thu Jan 8 23:22:06 CST 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv10842/channels

Modified Files:
	chan_zap.c 
Log Message:
Bug #736: Better checking to avoid chan_zap segfault re: ss_thread and zt_new()


Index: chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -d -r1.159 -r1.160
--- chan_zap.c	19 Dec 2003 16:08:10 -0000	1.159
+++ chan_zap.c	9 Jan 2004 05:13:50 -0000	1.160
@@ -3050,11 +3050,13 @@
 									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 @@
 		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);




More information about the svn-commits mailing list