From 1feba8bb02d26225f6ab013d50889a4d2e0c56f3 Mon Sep 17 00:00:00 2001 From: Gilles Debunne Date: Thu, 27 Jan 2011 18:35:40 -0800 Subject: [PATCH] Fix for an IOOBoundsException in Paint. 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index b739d838ca9d0..d8a7f9d57c7ad 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -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; }