From e5f51200a3d393ec70a26e485d8a260ef4919252 Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Sun, 30 Jan 2011 07:17:48 +0000 Subject: [PATCH] isWordSeparator crashes when checking end-of-paragraph git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37369 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Paragraph.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 08b143b364..8d7371ff5f 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -2847,11 +2847,12 @@ bool Paragraph::isWordSeparator(pos_type pos) const { if (Inset const * inset = getInset(pos)) return !inset->isLetter(); + if (pos == size()) + return true; char_type const c = d->text_[pos]; // We want to pass the ' and escape chars to the spellchecker static docstring const quote = from_utf8(lyxrc.spellchecker_esc_chars + '\''); - return (!isLetterChar(c) && !isDigitASCII(c) && !contains(quote, c)) - || pos == size(); + return (!isLetterChar(c) && !isDigitASCII(c) && !contains(quote, c)); } @@ -3766,7 +3767,9 @@ void Paragraph::spellCheck() const bool Paragraph::isMisspelled(pos_type pos, bool check_boundary) const { bool result = SpellChecker::misspelled(d->speller_state_.getState(pos)); - if (!result && check_boundary && pos > 0 && isWordSeparator(pos)) + if (result || pos <= 0 || pos >= size()) + return result; + if (check_boundary && isWordSeparator(pos)) result = SpellChecker::misspelled(d->speller_state_.getState(pos - 1)); return result; }