summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2015-06-11 20:46:53 +0900
committerKeisuke Kuroyanagi <ksk@google.com>2015-06-11 20:46:53 +0900
commitf2122ef549dd73f68bdbe4d6767f6516935024d0 (patch)
tree78859fc4a464ed897022c55ebc61cc60f9c7791e /graphics
parent4ba81a0878d058734e9eb2c298d7fc4df7e597ed (diff)
downloadframeworks_base-f2122ef549dd73f68bdbe4d6767f6516935024d0.zip
frameworks_base-f2122ef549dd73f68bdbe4d6767f6516935024d0.tar.gz
frameworks_base-f2122ef549dd73f68bdbe4d6767f6516935024d0.tar.bz2
Improve boundary check for for Paint#DrawTextRun.
Change-Id: I01027ebb9133240cc1c750824a41dd9fca484c1f
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/Canvas.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 392a5b6..7386637 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -1728,8 +1728,7 @@ public class Canvas {
* @param contextIndex the start of the context for shaping. Must be
* no greater than index.
* @param contextCount the number of characters in the context for shaping.
- * contexIndex + contextCount must be no less than index
- * + count.
+ * contexIndex + contextCount must be no less than index + count.
* @param x the x position at which to draw the text
* @param y the y position at which to draw the text
* @param isRtl whether the run is in RTL direction
@@ -1744,12 +1743,14 @@ public class Canvas {
if (paint == null) {
throw new NullPointerException("paint is null");
}
- if ((index | count | text.length - index - count) < 0) {
+ if ((index | count | contextIndex | contextCount | index - contextIndex
+ | (contextIndex + contextCount) - (index + count)
+ | text.length - (contextIndex + contextCount)) < 0) {
throw new IndexOutOfBoundsException();
}
- native_drawTextRun(mNativeCanvasWrapper, text, index, count,
- contextIndex, contextCount, x, y, isRtl, paint.getNativeInstance(), paint.mNativeTypeface);
+ native_drawTextRun(mNativeCanvasWrapper, text, index, count, contextIndex, contextCount,
+ x, y, isRtl, paint.getNativeInstance(), paint.mNativeTypeface);
}
/**
@@ -1796,14 +1797,15 @@ public class Canvas {
if (paint == null) {
throw new NullPointerException("paint is null");
}
- if ((start | end | end - start | text.length() - end) < 0) {
+ if ((start | end | contextStart | contextEnd | start - contextStart | end - start
+ | contextEnd - end | text.length() - contextEnd) < 0) {
throw new IndexOutOfBoundsException();
}
if (text instanceof String || text instanceof SpannedString ||
text instanceof SpannableString) {
- native_drawTextRun(mNativeCanvasWrapper, text.toString(), start, end,
- contextStart, contextEnd, x, y, isRtl, paint.getNativeInstance(), paint.mNativeTypeface);
+ native_drawTextRun(mNativeCanvasWrapper, text.toString(), start, end, contextStart,
+ contextEnd, x, y, isRtl, paint.getNativeInstance(), paint.mNativeTypeface);
} else if (text instanceof GraphicsOperations) {
((GraphicsOperations) text).drawTextRun(this, start, end,
contextStart, contextEnd, x, y, isRtl, paint);