Prevent out-of-bounds vector access

Bug: 230172711
Test: See bug for fuzzer testcase.
Test: atest CtsMiscMediaTestCases
Change-Id: I0c7a5940810d567c6bcb9045f35efb477437491a
Merged-In: I0c7a5940810d567c6bcb9045f35efb477437491a
(cherry picked from commit ba7d0869174bf07886a0df5f33f252511215e78b)
diff --git a/media/libstagefright/HevcUtils.cpp b/media/libstagefright/HevcUtils.cpp
index 5f9c20e..60df162 100644
--- a/media/libstagefright/HevcUtils.cpp
+++ b/media/libstagefright/HevcUtils.cpp
@@ -102,10 +102,11 @@
 static bool findParam(uint32_t key, T *param,
         KeyedVector<uint32_t, uint64_t> &params) {
     CHECK(param);
-    if (params.indexOfKey(key) < 0) {
+    ssize_t index = params.indexOfKey(key);
+    if (index < 0) {
         return false;
     }
-    *param = (T) params[key];
+    *param = (T) params[index];
     return true;
 }
 
OSZAR »