mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
read all data from input QByteArray data stream at once
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
975e1d7b88
commit
e424d28850
1 changed files with 5 additions and 13 deletions
|
@ -2819,19 +2819,11 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba)
|
|||
if (len == 0xffffffff)
|
||||
return in;
|
||||
|
||||
const quint32 Step = 1024 * 1024;
|
||||
quint32 allocated = 0;
|
||||
|
||||
do {
|
||||
int blockSize = qMin(Step, len - allocated);
|
||||
ba.resize(allocated + blockSize);
|
||||
if (in.readRawData(ba.data() + allocated, blockSize) != blockSize) {
|
||||
ba.clear();
|
||||
in.setStatus(QDataStream::ReadPastEnd);
|
||||
return in;
|
||||
}
|
||||
allocated += blockSize;
|
||||
} while (allocated < len);
|
||||
ba.resize(len);
|
||||
if (in.readRawData(ba.data(), len) != len) {
|
||||
ba.clear();
|
||||
in.setStatus(QDataStream::ReadCorruptData);
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue