]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Core] VAD: Add a math sanity check to the switch_vad_process 2465/head
authorAndrey Volk <andywolk@gmail.com>
Tue, 31 May 2022 21:09:48 +0000 (00:09 +0300)
committerAndrey Volk <andywolk@gmail.com>
Sun, 19 May 2024 18:22:31 +0000 (21:22 +0300)
src/switch_vad.c

index 6118c0237e5b2c8064012c792c9bf78c96b6d3c4..74d131331b739e9bea6cbc2267fdc039bf0d5765 100644 (file)
@@ -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