From c2a649c50edf7048e887765df763e456401954d9 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 7 Apr 2023 09:45:32 +0200 Subject: [PATCH] Prevent crash in emoji compat library when used right after the app started (cold start for a chat room shorcut for example) --- app/src/main/java/org/linphone/utils/AppUtils.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/linphone/utils/AppUtils.kt b/app/src/main/java/org/linphone/utils/AppUtils.kt index 00e17ff47..5f94a1b72 100644 --- a/app/src/main/java/org/linphone/utils/AppUtils.kt +++ b/app/src/main/java/org/linphone/utils/AppUtils.kt @@ -110,12 +110,20 @@ class AppUtils { val emoji = emojiCompat emoji ?: return false - for (split in text.split(" ")) { - // We only check the first and last chars of the split for commodity - if (emoji.getEmojiStart(split, 0) == -1 || emoji.getEmojiEnd(split, split.length - 1) == -1) { - return false + try { + for (split in text.split(" ")) { + // We only check the first and last chars of the split for commodity + if (emoji.getEmojiStart(split, 0) == -1 + || emoji.getEmojiEnd(split,split.length - 1) == -1) + { + return false + } } + } catch (npe: NullPointerException) { + // This can happen in EmojiCompat library, mProcessor can be null (https://issuetracker.google.com/issues/277182750) + return false } + return true }