From f5bc6c6fc8d93836a5914b52b0122b6ff6b433cd Mon Sep 17 00:00:00 2001 From: Ivan Kupalov Date: Sat, 20 Jul 2019 11:37:28 +0200 Subject: [PATCH] Fix crash on empty status messages (#1402) --- .../com/keylesspalace/tusky/util/SmartLengthInputFilter.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.kt b/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.kt index 82d13d87..eb738b06 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.kt @@ -38,7 +38,8 @@ private const val LENGTH_DEFAULT = 500 * @return Whether the message should be trimmed or not. */ fun shouldTrimStatus(message: Spanned): Boolean { - return LENGTH_DEFAULT / message.length > 0.75 + // Check for emptiness so that we don't divide by zero + return message.isNotEmpty() && LENGTH_DEFAULT.toFloat() / message.length > 0.75 } /**