diff options
Diffstat (limited to 'core/java/android/util/SparseLongArray.java')
| -rw-r--r-- | core/java/android/util/SparseLongArray.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/java/android/util/SparseLongArray.java b/core/java/android/util/SparseLongArray.java index 81db2b7ff715..37a92024f374 100644 --- a/core/java/android/util/SparseLongArray.java +++ b/core/java/android/util/SparseLongArray.java @@ -182,6 +182,10 @@ public class SparseLongArray implements Cloneable { * key.</p> */ public int keyAt(int index) { + if (index >= mSize) { + // The array might be slightly bigger than mSize, in which case, indexing won't fail. + throw new ArrayIndexOutOfBoundsException(index); + } return mKeys[index]; } @@ -197,6 +201,10 @@ public class SparseLongArray implements Cloneable { * associated with the largest key.</p> */ public long valueAt(int index) { + if (index >= mSize) { + // The array might be slightly bigger than mSize, in which case, indexing won't fail. + throw new ArrayIndexOutOfBoundsException(index); + } return mValues[index]; } |
