From 0da578c2a3d398925d4eb6e4da749831ef6dcf20 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Thu, 12 Oct 2023 08:16:24 +0800 Subject: [PATCH] fix: dsl dictionary crash when creating full text index. fix #1230 --- src/dict/dsl.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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; }