ma_listener: correct bounds of array
crashed by array index out of bounds.
Bug: 79468907
Bug: 79472606
Bug: 79495729
Test: manual audio test rington/music/alarm/notification
Change-Id: I327ef3b77c7c65064b67dfdc3404cf59d5d84203
Signed-off-by: Jasmine Cha <chajasmine@google.com>
diff --git a/post_proc/ma_listener.c b/post_proc/ma_listener.c
index 8e57db1..02d45d3 100644
--- a/post_proc/ma_listener.c
+++ b/post_proc/ma_listener.c
@@ -61,7 +61,7 @@
static const audio_stream_type_t MIN_STREAM_TYPES = AUDIO_STREAM_VOICE_CALL;
static const audio_stream_type_t MAX_STREAM_TYPES = AUDIO_STREAM_NOTIFICATION;
-static struct ma_state g_cur_state[MAX_STREAM_TYPES];
+static struct ma_state g_cur_state[MAX_STREAM_TYPES + 1];
struct ma_listener_context_s {
const struct effect_interface_s *itfe;
@@ -211,6 +211,8 @@
else if (max_vol > 1.0) max_vol = 1.0;
if (send_ma_parameter != NULL &&
+ stream_type >= MIN_STREAM_TYPES &&
+ stream_type <= MAX_STREAM_TYPES &&
(g_cur_state[stream_type].vol != max_vol ||
g_cur_state[stream_type].active != active)) {