diff --git a/src/dict/dsl.cc b/src/dict/dsl.cc index 2f2ea752..8a7342ec 100644 --- a/src/dict/dsl.cc +++ b/src/dict/dsl.cc @@ -1150,10 +1150,11 @@ void DslDictionary::getArticleText( uint32_t articleAddress, QString & headword, size_t begin = pos; pos = articleData.find_first_of( U"\n\r", begin ); + if ( pos == wstring::npos ) + pos = articleData.size(); if ( articleHeadword.empty() ) { // Process the headword - articleHeadword = wstring( articleData, begin, pos - begin ); if ( insidedCard && !articleHeadword.empty() && isDslWs( articleHeadword[ 0 ] ) ) { @@ -1195,12 +1196,12 @@ void DslDictionary::getArticleText( uint32_t articleAddress, QString & headword, if ( articleData[ pos ] == '\r' ) ++pos; - if ( pos != articleData.size() ) { + if ( pos < articleData.size() ) { if ( articleData[ pos ] == '\n' ) ++pos; } - if ( pos == articleData.size() ) { + if ( pos >= articleData.size() ) { // Ok, it's end of article break; }