From 04a84559fd11b36196872b1ac0cb82e5f7367806 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Thu, 9 Jul 2015 15:38:04 -0700 Subject: [PATCH] Fix StaticLayout crash when maxLines = 0 An app setting maxLines = 0 is an edge case, but it can happen. We had some logic that would index an array at -1 in that case. This patch just skips the fixup of the ellipsis line break in that case. Bug: 22353342 Change-Id: I940cf0782b319010f5aedf75b9291df4ac2976d8 --- core/java/android/text/StaticLayout.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index cdff395a3fa91..efc9e1ae4aa60 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -744,7 +744,8 @@ public class StaticLayout extends Layout { && (ellipsize == TextUtils.TruncateAt.END || (mMaximumVisibleLineCount == 1 && ellipsize != TextUtils.TruncateAt.MARQUEE)); - if (remainingLineCount < breakCount && ellipsisMayBeApplied) { + if (remainingLineCount > 0 && remainingLineCount < breakCount && + ellipsisMayBeApplied) { // Treat the last line and overflowed lines as a single line. breaks[remainingLineCount - 1] = breaks[breakCount - 1]; // Calculate width and flag.