Avoid reading outside of memory in WebRtcVad_FindMinimum
Also, change test target from rtc_static_library to rtc_source_set so that it is actually linked and run.
Bug: webrtc:11010, webrtc:11037
Change-Id: I05173718ee7de8a9fad73b62c0efd0da4d4f1a7e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157166
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29509}
diff --git a/common_audio/vad/vad_sp.c b/common_audio/vad/vad_sp.c
index d367c8b..d710a37 100644
--- a/common_audio/vad/vad_sp.c
+++ b/common_audio/vad/vad_sp.c
@@ -79,7 +79,7 @@
age[i]++;
} else {
// Too old value. Remove from memory and shift larger values downwards.
- for (j = i; j < 16; j++) {
+ for (j = i; j < 15; j++) {
smallest_values[j] = smallest_values[j + 1];
age[j] = age[j + 1];
}
diff --git a/modules/audio_processing/vad/BUILD.gn b/modules/audio_processing/vad/BUILD.gn
index bf99115..8eb59c9 100644
--- a/modules/audio_processing/vad/BUILD.gn
+++ b/modules/audio_processing/vad/BUILD.gn
@@ -45,7 +45,7 @@
}
if (rtc_include_tests) {
- rtc_static_library("vad_unittests") {
+ rtc_source_set("vad_unittests") {
testonly = true
sources = [
"gmm_unittest.cc",