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
import org.json.JSONObject;
import java.io.PrintWriter;
+import java.lang.Math;
import java.util.ArrayDeque;
import java.util.Calendar;
import java.util.GregorianCalendar;
}
void increment(int imp) {
- imp = imp < 0 ? 0 : imp > NUM_IMPORTANCES ? NUM_IMPORTANCES : imp;
- mCount[imp] ++;
+ imp = Math.max(0, Math.min(imp, mCount.length - 1));
+ mCount[imp]++;
}
void maybeCount(ImportanceHistogram prev) {