Fix possible out of bounds accesses Bug: 30074856 Change-Id: I1a1387ed29d2e0d010b0d5d4bb3d29453a3a7666 (cherry picked from commit ee54e6ceb66e16b3c10c4a9fc8fbe5fff9110b62)