mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
fix: dict.org crashes by incomplete response and str out of bound access
This commit is contained in:
parent
8fc71c9586
commit
f59b04565a
|
@ -538,14 +538,22 @@ void DictServerWordSearchRequest::readMatchData( QByteArray & reply )
|
|||
if ( word.endsWith( '\"' ) ) {
|
||||
word.chop( 1 );
|
||||
}
|
||||
if ( word[ 0 ] == '\"' ) {
|
||||
if ( word.startsWith( '\"' ) ) {
|
||||
word = word.mid( 1 );
|
||||
}
|
||||
|
||||
this->addMatchedWord( word );
|
||||
if ( !word.isEmpty() ) {
|
||||
this->addMatchedWord( word );
|
||||
}
|
||||
}
|
||||
|
||||
reply = this->dictImpl->socket.readLine();
|
||||
constexpr int halfSecond = 500;
|
||||
if ( this->dictImpl->socket.waitForReadyRead( halfSecond ) ) {
|
||||
reply = this->dictImpl->socket.readLine();
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
} while ( true );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue