void-packages/srcpkgs/electron33/patches/spellchecker-infinate-loop.patch
2025-02-05 08:26:09 +01:00

31 lines
1.4 KiB
Diff

From 9f6ee267adabcbd3348dd1a4daf57843aef14050 Mon Sep 17 00:00:00 2001
From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com>
Date: Fri, 13 Dec 2024 16:47:55 +0000
Subject: [PATCH] fix: custom spell-checker stuck in infinite loop
`ReadUnicodeCharacter` updates index to the last character read, and not after it. We need to manually increment it to move to the next character.
It also doesn't validate that the index is valid, so we need to check that index is within bounds.
Refs: #44336
Co-authored-by: Jesper Ek <deadbeef84@gmail.com>
---
shell/renderer/api/electron_api_spell_check_client.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/shell/renderer/api/electron_api_spell_check_client.cc b/shell/renderer/api/electron_api_spell_check_client.cc
index b97f1771ff723..95e05ecccb524 100644
--- a/src/electron/shell/renderer/api/electron_api_spell_check_client.cc
+++ b/src/electron/shell/renderer/api/electron_api_spell_check_client.cc
@@ -32,7 +32,9 @@ namespace {
bool HasWordCharacters(const std::u16string& text, size_t index) {
base_icu::UChar32 code;
- while (base::ReadUnicodeCharacter(text.c_str(), text.size(), &index, &code)) {
+ while (index < text.size() &&
+ base::ReadUnicodeCharacter(text.c_str(), text.size(), &index, &code)) {
+ ++index;
UErrorCode error = U_ZERO_ERROR;
if (uscript_getScript(code, &error) != USCRIPT_COMMON)
return true;