OSDN Git Service

audio_route: skip missing controls
authorSimon Wilson <simonwilson@google.com>
Mon, 13 May 2013 19:47:41 +0000 (12:47 -0700)
committerSimon Wilson <simonwilson@google.com>
Mon, 13 May 2013 19:52:53 +0000 (12:52 -0700)
Mixer controls that are in mixer_paths.xml but missing from
the mixer should be skipped, otherwise arrays will be accessed
out of bounds. This happened in b/8893515.

Also print the missing control name to aid debugging.

Change-Id: Ia808df48734f78a02281408a4025652dec9762c0

audio_route/audio_route.c

index b935904..da7585c 100644 (file)
@@ -405,6 +405,11 @@ static void start_tag(void *data, const XML_Char *tag_name,
     else if (strcmp(tag_name, "ctl") == 0) {
         /* Obtain the mixer ctl and value */
         ctl = mixer_get_ctl_by_name(ar->mixer, attr_name);
+        if (ctl == NULL) {
+            ALOGE("Control '%s' doesn't exist - skipping", attr_name);
+            goto done;
+        }
+
         switch (mixer_ctl_get_type(ctl)) {
         case MIXER_CTL_TYPE_BOOL:
         case MIXER_CTL_TYPE_INT:
@@ -464,6 +469,7 @@ static void start_tag(void *data, const XML_Char *tag_name,
         }
     }
 
+done:
     state->level++;
 }