]> git.lyx.org Git - features.git/commitdiff
MSVC: Add safety checks.
authorAbdelrazak Younes <younes@lyx.org>
Mon, 22 Jun 2009 21:06:25 +0000 (21:06 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 22 Jun 2009 21:06:25 +0000 (21:06 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30229 a592a061-630c-0410-9148-cb99ea01b6c8

src/Paragraph.cpp

index 23acf9365b24ac392b9a6fade38c31833f06aa8c..47f08d22cf857c3dd87de133a3e1c6b81717a0bd 100644 (file)
@@ -3085,11 +3085,14 @@ bool Paragraph::spellCheck(pos_type & from, pos_type & to, WordLangTuple & wl,
        docstring_list & suggestions) const
 {
        SpellChecker * speller = theSpellChecker();
-       locateWord(from, to, WHOLE_WORD);
-       docstring word = asString(from, to, AS_STR_INSETS);
        if (!speller)
                return false;
 
+       locateWord(from, to, WHOLE_WORD);
+       if (from >= pos_type(d->text_.size()))
+               return false;
+
+       docstring word = asString(from, to, AS_STR_INSETS);
        string const lang_code = lyxrc.spellchecker_alt_lang.empty()
                ? getFontSettings(d->inset_owner_->buffer().params(), from).language()->code()
                : lyxrc.spellchecker_alt_lang;
@@ -3107,9 +3110,10 @@ bool Paragraph::spellCheck(pos_type & from, pos_type & to, WordLangTuple & wl,
        if (lyxrc.spellcheck_continuously)
                d->fontlist_.setMisspelled(from, to, misspelled);
 
-       while (!(word = speller->nextMiss()).empty())
-               suggestions.push_back(word);
-
+       if (misspelled) {
+               while (!(word = speller->nextMiss()).empty())
+                       suggestions.push_back(word);
+       }
        return misspelled;
 }