Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8bfa584 authored by yograj's avatar yograj Committed by Steve Kondik
Browse files

IndexOutOfBoundsException observed in ProcessStats

Sometime, IndexOutOfBoundsException is observed in ProcessStats
while allocating longs array. This could be due to synchronization.
This fix will return if array index is >= size.

Change-Id: I1302e6b88a3e94249f811fe682f1b0944b5d4e8a
parent 066156fe
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2871,6 +2871,9 @@ public final class ProcessStats implements Parcelable {
                mDurationsTable = mStats.mAddLongTable;
                mDurationsTableSize = mStats.mAddLongTableSize;
            }
            if (((off>>OFFSET_ARRAY_SHIFT)&OFFSET_ARRAY_MASK) >= mStats.mLongs.size()) {
                return;
            }
            long[] longs = mStats.mLongs.get((off>>OFFSET_ARRAY_SHIFT)&OFFSET_ARRAY_MASK);
            if (DEBUG) Slog.d(TAG, "Duration of " + mName + " state " + state + " inc by " + dur
                    + " from " + longs[(off>>OFFSET_INDEX_SHIFT)&OFFSET_INDEX_MASK]);
@@ -3251,6 +3254,9 @@ public final class ProcessStats implements Parcelable {
                mPssTable = mStats.mAddLongTable;
                mPssTableSize = mStats.mAddLongTableSize;
            }
            if (((off>>OFFSET_ARRAY_SHIFT)&OFFSET_ARRAY_MASK) >= mStats.mLongs.size()) {
                return;
            }
            long[] longs = mStats.mLongs.get((off>>OFFSET_ARRAY_SHIFT)&OFFSET_ARRAY_MASK);
            idx = (off>>OFFSET_INDEX_SHIFT)&OFFSET_INDEX_MASK;
            long count = longs[idx+PSS_SAMPLE_COUNT];