diff options
author | Eric Laurent <elaurent@google.com> | 2016-10-13 00:19:40 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-10-13 00:19:40 +0000 |
commit | e12085b0c596a85192fb124a0d5f8c652b55a3ef (patch) | |
tree | 4893f6efc0e44030f18e7770d0c71c3226479902 | |
parent | 4eb2a5da1db1481f099d79f1cbb0dd37d90e3bc6 (diff) | |
parent | ff3e6f401eb371bd51eaed91bfec1728ec22f3d1 (diff) | |
download | media-e12085b0c596a85192fb124a0d5f8c652b55a3ef.tar.gz |
audio_route: add check on enum valuesandroid-7.1.2_r9android-7.1.2_r8android-7.1.2_r6android-7.1.2_r5android-7.1.2_r4android-7.1.2_r36android-7.1.2_r33android-7.1.2_r32android-7.1.2_r30android-7.1.2_r3android-7.1.2_r29android-7.1.2_r28android-7.1.2_r27android-7.1.2_r25android-7.1.2_r24android-7.1.2_r23android-7.1.2_r2android-7.1.2_r19android-7.1.2_r18android-7.1.2_r17android-7.1.2_r16android-7.1.2_r15android-7.1.2_r14android-7.1.2_r13android-7.1.2_r12android-7.1.2_r11android-7.1.2_r10android-7.1.2_r1nougat-mr2.3-releasenougat-mr2.2-releasenougat-mr2.1-releasenougat-mr2-releasenougat-mr2-pixel-releasenougat-mr2-dev
am: ff3e6f401e
Change-Id: I4a9cfe96aac7472dde381cbb8756353d3cd128f2
-rw-r--r-- | audio_route/audio_route.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/audio_route/audio_route.c b/audio_route/audio_route.c index 90b114d5..bd5c1124 100644 --- a/audio_route/audio_route.c +++ b/audio_route/audio_route.c @@ -420,13 +420,24 @@ static int path_reset(struct audio_route *ar, struct mixer_path *path) static int mixer_enum_string_to_value(struct mixer_ctl *ctl, const char *string) { unsigned int i; + unsigned int num_values = mixer_ctl_get_num_enums(ctl); + + if (string == NULL) { + ALOGE("NULL enum value string passed to mixer_enum_string_to_value() for ctl %s", + mixer_ctl_get_name(ctl)); + return 0; + } /* Search the enum strings for a particular one */ - for (i = 0; i < mixer_ctl_get_num_enums(ctl); i++) { + for (i = 0; i < num_values; i++) { if (strcmp(mixer_ctl_get_enum_string(ctl, i), string) == 0) break; } - + if (i == num_values) { + ALOGE("unknown enum value string %s for ctl %s", + string, mixer_ctl_get_name(ctl)); + return 0; + } return i; } |