From e09cdf9c3a7beab21cbcc2843e1a948ce25852ca Mon Sep 17 00:00:00 2001 From: Seven Du Date: Fri, 27 Sep 2013 03:31:21 +0800 Subject: [PATCH] fix crash on zstr --- src/mod/applications/mod_sonar/mod_sonar.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mod/applications/mod_sonar/mod_sonar.c b/src/mod/applications/mod_sonar/mod_sonar.c index 4453deea90..5a1074e08d 100644 --- a/src/mod/applications/mod_sonar/mod_sonar.c +++ b/src/mod/applications/mod_sonar/mod_sonar.c @@ -70,9 +70,16 @@ SWITCH_STANDARD_APP(sonar_app) { switch_channel_t *channel = switch_core_session_get_channel(session); char *tone = "%(500,0,1004)"; - int loops = atoi(data); - - if ( ! loops ) { + const char *arg = (char *) data; + int loops; + + if (zstr(arg)) { + loops = 5; + } else { + loops = atoi(data); + } + + if (loops < 0) { loops = 5; }