From 60919953ce80dbf75673837ea51497c84da7ac78 Mon Sep 17 00:00:00 2001 From: Mark Wagner Date: Mon, 1 Mar 2010 09:24:59 -0800 Subject: [PATCH] check offset and don't crash --- core/java/android/text/TextUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java index afb22acef433..9589bf369e6e 100644 --- a/core/java/android/text/TextUtils.java +++ b/core/java/android/text/TextUtils.java @@ -1557,13 +1557,17 @@ public class TextUtils { * @param reqModes The modes to be checked: may be any combination of * {@link #CAP_MODE_CHARACTERS}, {@link #CAP_MODE_WORDS}, and * {@link #CAP_MODE_SENTENCES}. - * + * * @return Returns the actual capitalization modes that can be in effect * at the current position, which is any combination of * {@link #CAP_MODE_CHARACTERS}, {@link #CAP_MODE_WORDS}, and * {@link #CAP_MODE_SENTENCES}. */ public static int getCapsMode(CharSequence cs, int off, int reqModes) { + if (off < 0) { + return 0; + } + int i; char c; int mode = 0; -- 2.11.0