kdecore: use the QString streaming operator in KSycocaEntry::read()

any change to the QString streaming operator would break reading of entries

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-10-31 01:18:46 +02:00
parent 92816d2320
commit 0d54213264
2 changed files with 26 additions and 45 deletions

View file

@ -22,10 +22,10 @@
#include <ksycoca.h>
KSycocaEntryPrivate::KSycocaEntryPrivate(QDataStream &_str, int iOffset)
KSycocaEntryPrivate::KSycocaEntryPrivate(QDataStream &s, int iOffset)
: offset(iOffset), deleted(false)
{
KSycocaEntry::read( _str, path );
KSycocaEntry::read(s, path);
}
KSycocaEntry::KSycocaEntry()
@ -45,27 +45,11 @@ KSycocaEntry::~KSycocaEntry()
void KSycocaEntry::read(QDataStream &s, QString &str)
{
quint32 bytes;
s >> bytes; // read size of string
if ( bytes > 8192 ) { // null string or too big
if (bytes != 0xffffffff)
s >> str;
if (s.status() != QDataStream::Ok) {
KSycoca::flagError();
str.clear();
}
else if ( bytes > 0 ) { // not empty
int bt = bytes/2;
str.resize( bt );
QChar* ch = (QChar *) str.unicode();
char t[8192];
char *b = t;
s.readRawData( b, bytes );
while ( bt-- ) {
*ch++ = (ushort) (((ushort)b[0])<<8) | (uchar)b[1];
b += 2;
}
} else {
str.clear();
}
}
void KSycocaEntry::read(QDataStream &s, QStringList &list)
@ -73,18 +57,15 @@ void KSycocaEntry::read( QDataStream &s, QStringList &list )
list.clear();
quint32 count;
s >> count; // read size of list
if (count >= 1024)
{
if (count >= 1024) {
KSycoca::flagError();
return;
}
for(quint32 i = 0; i < count; i++)
{
for(quint32 i = 0; i < count; i++) {
QString str;
read(s, str);
list.append(str);
if (s.atEnd())
{
if (s.atEnd()) {
KSycoca::flagError();
return;
}