QCamera2: HAL3: Avoid array overrun for face detection

Bug: 28941005
Change-Id: I651c12d31378f8410b1fea7c19726116f1f84ecb
diff --git a/camera/QCamera2/HAL3/QCamera3HWI.cpp b/camera/QCamera2/HAL3/QCamera3HWI.cpp
index cbf23d3..c35a7f0 100644
--- a/camera/QCamera2/HAL3/QCamera3HWI.cpp
+++ b/camera/QCamera2/HAL3/QCamera3HWI.cpp
@@ -2984,7 +2984,7 @@
     if (IS_META_AVAILABLE(CAM_INTF_META_FACE_DETECTION, metadata)){
         cam_face_detection_data_t *faceDetectionInfo =
             (cam_face_detection_data_t *)POINTER_OF_META(CAM_INTF_META_FACE_DETECTION, metadata);
-        uint8_t numFaces = faceDetectionInfo->num_faces_detected;
+        uint8_t numFaces = MIN(faceDetectionInfo->num_faces_detected, MAX_ROI);
         int32_t faceIds[MAX_ROI];
         uint8_t faceScores[MAX_ROI];
         int32_t faceRectangles[MAX_ROI * 4];