From 85400015b7eed420f49bfde85cd08acc44f48b28 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 1 Jun 2022 00:09:48 +0300 Subject: [PATCH] [Core] VAD: Add a math sanity check to the switch_vad_process --- src/switch_vad.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/switch_vad.c b/src/switch_vad.c index 6118c0237e..74d131331b 100644 --- a/src/switch_vad.c +++ b/src/switch_vad.c @@ -206,7 +206,9 @@ SWITCH_DECLARE(switch_vad_state_t) switch_vad_process(switch_vad_t *vad, int16_t j += vad->channels; } - score = (uint32_t) (energy / (samples / vad->divisor)); + if (samples && vad->divisor && samples >= vad->divisor) { + score = (uint32_t)(energy / (samples / vad->divisor)); + } #ifdef SWITCH_HAVE_FVAD } #endif