ui: Fix array out of bound

Add check to prevent out of bound access

CRs-Fixed: 2231954
Change-Id: I66f5818dc452d983024599bcc95be5fd3104b264
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diff --git a/libs/gui/FrameTimestamps.cpp b/libs/gui/FrameTimestamps.cpp
index c04d907..ce1ead0 100644
--- a/libs/gui/FrameTimestamps.cpp
+++ b/libs/gui/FrameTimestamps.cpp
@@ -369,6 +369,10 @@
     newTimestamps.requestedPresentTime = newEntry.requestedPresentTime;
     newTimestamps.acquireFence = newEntry.acquireFence;
     newTimestamps.valid = true;
+    if (mQueueOffset >= MAX_FRAME_HISTORY) {
+        ALOGE_IF(mProducerWantsEvents, "addQueue: QueueOffset is out of bound");
+        return;
+    }
     mFrames[mQueueOffset] = newTimestamps;
 
     // Note: We avoid sending the acquire fence back to the caller since