Merge pull request #1231 from xiaoyifang/fix/dsl-crash

fix: dsl dictionary crash when creating full text index.
This commit is contained in:
xiaoyifang 2023-10-12 21:15:49 +08:00 committed by GitHub
commit 19fff3e445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}