OSDN Git Service

Trebuchet: Fix possible OOB
authorMichael W <baddaemon87@gmail.com>
Tue, 17 May 2016 22:02:11 +0000 (00:02 +0200)
committerGerrit Code Review <gerrit@cyanogenmod.org>
Wed, 18 May 2016 16:09:59 +0000 (09:09 -0700)
In some cases mText is empty and Substring will then throw an OOB
Add logic to fix this

(Reference: BugReports 13-20160506-12, Line #157)

Change-Id: I2b32b0a56a93977d34b780afb9b3047e9fa566b0

src/com/android/launcher3/AutoExpandTextView.java

index ea7ac89..4dd4199 100644 (file)
@@ -197,11 +197,14 @@ public class AutoExpandTextView extends TextView {
 
         SpannableStringBuilder builder = new SpannableStringBuilder();
         for (HighlightedText highlightText : sections) {
-            SpannableString spannable = new SpannableString(highlightText.mText.substring(0, 1));
-            spannable.setSpan(
-                    new ForegroundColorSpan(highlightText.mHighlight ? highlightColor : grayColor),
-                    0, spannable.length(), 0);
-            builder.append(spannable);
+            if (!TextUtils.isEmpty(highlightText.mText)) {
+                SpannableString spannable =
+                        new SpannableString(highlightText.mText.substring(0, 1));
+                spannable.setSpan(
+                        new ForegroundColorSpan(highlightText.mHighlight ? highlightColor :
+                                grayColor), 0, spannable.length(), 0);
+                builder.append(spannable);
+            }
         }
 
         setText(builder);