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

Commit ea50f804 authored by Kouji Shiotani's avatar Kouji Shiotani Committed by Shunta Sato
Browse files

Fix wrong array index bound in NotificationUsageStats

Symptom:
It's possible to cause ArrayIndexOutOfBoundsException.

Root cause:
There is an error in the argument check, there is a possibility of
accessing an incorrect Index

Solution:
Fix the argument check correctly

Bug: 36542230

Change-Id: I3dea387c4a2bbddcc68db06812b57fd9d300f778
parent 4a895309
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import org.json.JSONException;
import org.json.JSONObject;

import java.io.PrintWriter;
import java.lang.Math;
import java.util.ArrayDeque;
import java.util.Calendar;
import java.util.GregorianCalendar;
@@ -718,7 +719,7 @@ public class NotificationUsageStats {
        }

        void increment(int imp) {
            imp = imp < 0 ? 0 : imp > NUM_IMPORTANCES ? NUM_IMPORTANCES : imp;
            imp = Math.max(0, Math.min(imp, mCount.length - 1));
            mCount[imp]++;
        }