OSDN Git Service

Fix for an IOOBoundsException in Paint.
authorGilles Debunne <debunne@google.com>
Fri, 28 Jan 2011 02:35:40 +0000 (18:35 -0800)
committerGilles Debunne <debunne@google.com>
Fri, 28 Jan 2011 02:39:42 +0000 (18:39 -0800)
Bug 3331706

The temporary buffer starts at index 0 and shifts indexes by contextStart.
offset has to be changed accordingly.

Note that I didn't try to reproduce the monkey bug after this fix, but it
seems like a perfect explanation for the exception.

Change-Id: Ie69adc413670caed283bc46effc69f17a102922c

graphics/java/android/graphics/Paint.java

index b739d83..d8a7f9d 100644 (file)
@@ -1690,7 +1690,7 @@ public class Paint {
         int contextLen = contextEnd - contextStart;
         char[] buf = TemporaryBuffer.obtain(contextLen);
         TextUtils.getChars(text, contextStart, contextEnd, buf, 0);
-        int result = getTextRunCursor(buf, 0, contextLen, flags, offset, cursorOpt);
+        int result = getTextRunCursor(buf, 0, contextLen, flags, offset - contextStart, cursorOpt);
         TemporaryBuffer.recycle(buf);
         return result;
     }