From bb9702430048d9c36c90ea11e9a38a7b52ef6665 Mon Sep 17 00:00:00 2001 From: Beq Date: Sat, 16 Mar 2024 19:57:22 +0000 Subject: [PATCH] FIRE-33773 - avoid OOB access under certain conditions --- indra/llui/llemojihelper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/llui/llemojihelper.cpp b/indra/llui/llemojihelper.cpp index cf431b4039..96e92f3379 100644 --- a/indra/llui/llemojihelper.cpp +++ b/indra/llui/llemojihelper.cpp @@ -64,7 +64,7 @@ bool LLEmojiHelper::isCursorInEmojiCode(const LLWString& wtext, S32 cursorPos, S return false; } // - + if (cursorPos < 0 || wtext.size() < cursorPos) return false; // FIRE-33773 - fix logic to avoid OOB access to wtext // If the cursor is currently on a colon start the check one character further back S32 shortCodePos = (cursorPos == 0 || L':' != wtext[cursorPos - 1]) ? cursorPos : cursorPos - 1; @@ -84,7 +84,7 @@ bool LLEmojiHelper::isCursorInEmojiCode(const LLWString& wtext, S32 cursorPos, S shortCodePos--; } - bool isShortCode = (L':' == wtext[shortCodePos - 1]) && (cursorPos - shortCodePos >= 2); + bool isShortCode = (cursorPos - shortCodePos >= 2) && (L':' == wtext[shortCodePos - 1]); // FIRE-33773 - fix logic to avoid OOB access to wtext if (pShortCodePos) *pShortCodePos = (isShortCode) ? shortCodePos - 1 : -1; return isShortCode;