From 76aaecb221d5d1a39719658635b2b65a670b4648 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 22 Jun 2009 21:06:25 +0000 Subject: [PATCH] MSVC: Add safety checks. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30229 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Paragraph.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 23acf9365b..47f08d22cf 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -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; } -- 2.39.2