diff options
| author | 2016-08-26 15:23:47 -0700 | |
|---|---|---|
| committer | 2016-08-30 14:27:22 -0700 | |
| commit | 9f3958cc2ba3da1406caac64650620d226bf8562 (patch) | |
| tree | 5732192794ebb71d8da7eef83e84aa6c94f4576b | |
| parent | 885f6495ac05c40753eb133bdf2d7e1f276986a2 (diff) | |
TextLine.handleRun should throw exception for invalid index
TextLine.handleRun caused infinite loop if measureLimit is out of bounds
of start and end parameters (for Spannables). For regular String it used
to throw a similar exception in handleText. This CL verifies what is
written in ApiDoc: measureLimit should be between start and limit
inclusive.
Bug: 30985145
Change-Id: I0659e8887f7b43ed2047d08b99bf86d8df80a21c
| -rw-r--r-- | core/java/android/text/TextLine.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java index 2a52961984f7..c4118605b44c 100644 --- a/core/java/android/text/TextLine.java +++ b/core/java/android/text/TextLine.java @@ -16,11 +16,9 @@ package android.text; -import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.FontMetricsInt; -import android.graphics.RectF; import android.text.Layout.Directions; import android.text.Layout.TabStops; import android.text.style.CharacterStyle; @@ -852,6 +850,11 @@ class TextLine { int limit, boolean runIsRtl, Canvas c, float x, int top, int y, int bottom, FontMetricsInt fmi, boolean needWidth) { + if (measureLimit < start || measureLimit > limit) { + throw new IndexOutOfBoundsException("measureLimit (" + measureLimit + ") is out of " + + "start (" + start + ") and limit (" + limit + ") bounds"); + } + // Case of an empty line, make sure we update fmi according to mPaint if (start == measureLimit) { TextPaint wp = mWorkPaint; |