From 0a4a0958b7743d116f92662de1da26c9321b56ef Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Tue, 12 Nov 2024 16:32:32 -0500 Subject: [PATCH] fix: a DICT crash caused by string out of bound access --- src/dict/dictserver.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dict/dictserver.cc b/src/dict/dictserver.cc index ef1e9bcf..f3cac418 100644 --- a/src/dict/dictserver.cc +++ b/src/dict/dictserver.cc @@ -538,11 +538,13 @@ void DictServerWordSearchRequest::readMatchData( QByteArray & reply ) if ( word.endsWith( '\"' ) ) { word.chop( 1 ); } - if ( word[ 0 ] == '\"' ) { - word = word.mid( 1 ); + if ( word.startsWith( '\"' ) ) { + word = word.remove( 0, 1 ); } - this->addMatchedWord( word ); + if ( !word.isEmpty() ) { + this->addMatchedWord( word ); + } } reply = this->dictImpl->socket.readLine();