am 505ffe36: Merge "Check bounds on CharSequence drawText methods" into lmp-mr1-dev

* commit '505ffe3633f45778e493e23ad8c163f09ed1dbb5':
  Check bounds on CharSequence drawText methods
This commit is contained in:
Raph Levien
2014-11-14 20:56:46 +00:00
committed by Android Git Automerger
2 changed files with 6 additions and 0 deletions

View File

@@ -885,6 +885,9 @@ class GLES20Canvas extends HardwareCanvas {
@Override
public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
if ((start | end | (end - start) | (text.length() - end)) < 0) {
throw new IndexOutOfBoundsException();
}
if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) {
nDrawText(mRenderer, text.toString(), start, end, x, y, paint.mBidiFlags,

View File

@@ -1710,6 +1710,9 @@ public class Canvas {
*/
public void drawText(@NonNull CharSequence text, int start, int end, float x, float y,
@NonNull Paint paint) {
if ((start | end | (end - start) | (text.length() - end)) < 0) {
throw new IndexOutOfBoundsException();
}
if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) {
native_drawText(mNativeCanvasWrapper, text.toString(), start, end, x, y,