From d06a2c7e0a2a1b2f738bb0241428b3a33b25e4a7 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 15 Dec 2006 17:01:01 +0000 Subject: [PATCH] avoid potential div by zero git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3670 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../applications/mod_conference/mod_conference.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 6a6678b254..566c20562e 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -3256,14 +3256,15 @@ static void *SWITCH_THREAD_FUNC input_thread_run(switch_thread_t *thread, void * int16_t *data; data = read_frame->data; - samples = read_frame->datalen / sizeof(*data); + if ((samples = read_frame->datalen / sizeof(*data))) { - for (i = 0; i < samples; i++) { - energy += abs(data[j]); - j += read_codec->implementation->number_of_channels; - } + for (i = 0; i < samples; i++) { + energy += abs(data[j]); + j += read_codec->implementation->number_of_channels; + } - score = energy / samples; + score = energy / samples; + } if (score > energy_level) { uint32_t diff = score - energy_level;