From 6865b02547bc6ae3933a0d5d714801860b92f978 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 5bdce93d..a30ba09a 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();