Check tempchan->type in app_zapscan.c (bug 1250)
[asterisk/asterisk.git] / apps / app_zapscan.c
index 502aa5a..b24fe5d 100755 (executable)
@@ -256,8 +256,10 @@ static int conf_exec(struct ast_channel *chan, void *data)
                 ast_answer(chan);
 
         for (;;) {
+               if (ast_waitfor(chan, 100) < 0)
+                       break;
                f = ast_read(chan);
-               if (!f || ast_check_hangup(chan))
+               if (!f)
                        break;
                if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '*')) {
                        ast_frfree(f);
@@ -267,7 +269,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
                 tempchan = ast_channel_walk(tempchan);
                 if ( !tempchan && !lastchan )
                         break;
-                if ( tempchan && (!strcmp(tempchan->type, "Zap")) && (tempchan != chan) ) {
+                if ( tempchan && tempchan->type && (!strcmp(tempchan->type, "Zap")) && (tempchan != chan) ) {
                         ast_verbose(VERBOSE_PREFIX_3 "Zap channel %s is in-use, monitoring...\n", tempchan->name);
                         strcpy(confstr, tempchan->name);
                         if ((tmp = strchr(confstr,'-'))) {