From 1e3b77824e7b059951ff318fd359d82d19590d13 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Wed, 5 Apr 2023 10:24:41 +0200 Subject: [PATCH] Fix crash caused by empty span when removing leading newlines Change-Id: I9045bf1314b15d3672d1837bca29fa4af4c0fdbd --- .../main/java/im/vector/app/features/html/EventHtmlRenderer.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt b/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt index 4bfed12f3a..49acd4dbaa 100644 --- a/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt +++ b/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt @@ -277,6 +277,9 @@ class EventHtmlRenderer @Inject constructor( spans.forEach { span -> val start = text.getSpanStart(span) + if (start < 0) { + return@forEach + } if (text[start] == '\n') { text.replace(start, start + 1, "") }