commit 5815ff23ff87f94ba58c24501b9d5f7224959e5a
Author: Stephan Witt <[email protected]>
Date:   Sun Dec 14 16:15:38 2025 +0100

    #13261 add check for broken position and length of spell check ranges
    
    (cherry picked from commit b83bd16d8ac921df3d92641449e66f6cc1729e97)
---
 src/Paragraph.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 78ba89e1d8..2deabacfd0 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -5278,13 +5278,21 @@ void Paragraph::Private::markMisspelledWords(
        int numskipped = 0;
        SkipPositionsIterator it = skips.begin();
        SkipPositionsIterator et = skips.end();
+       int wsize = word.size();
        for (int index = 0; index < nerrors; ++index) {
                int wstart;
                int wlen = 0;
                speller->misspelledWord(index, wstart, wlen);
                /// should not happen if speller supports range checks
-               if (!wlen)
+               if (0 == wlen)
                        continue;
+               if (wstart + wlen > wsize) {
+                       LYXERR(Debug::GUI, "OUTSIDE of word: \"" <<
+                                  word << "\" [" <<
+                                  wstart << ".." << (wstart + wlen) << "]" <<
+                                  " word size: " << wsize);
+                       break;
+               }
                WordLangTuple const candidate(word.substr(wstart, wlen), lang);
                wstart += first + numskipped;
                if (snext < wstart) {
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to