From 74fd81ef380725beccf2d277c1574cc04d82085a Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Wed, 3 Jul 2024 10:48:41 +0200 Subject: [PATCH] Fix "setSpan ends beyond length" crash on Android (#411) --- .../main/java/com/expensify/livemarkdown/MarkdownUtils.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/src/main/java/com/expensify/livemarkdown/MarkdownUtils.java b/android/src/main/java/com/expensify/livemarkdown/MarkdownUtils.java index cf7cf5ff..7711d8b7 100644 --- a/android/src/main/java/com/expensify/livemarkdown/MarkdownUtils.java +++ b/android/src/main/java/com/expensify/livemarkdown/MarkdownUtils.java @@ -94,6 +94,9 @@ public void applyMarkdownFormatting(SpannableStringBuilder ssb) { int length = range.getInt("length"); int depth = range.optInt("depth", 1); int end = start + length; + if (length == 0 || end > input.length()) { + continue; + } applyRange(ssb, type, start, end, depth); } } catch (JSONException e) {