KCompressionDevice::seek: Fix previous fix ^_^

Authored by aacid on May 27 2019, 7:18 AM.

Description

KCompressionDevice::seek: Fix previous fix ^_^

Summary:
The previous fix that made sure we returned the actual data in KCompressionDevice::readData
because it is sometimes buffered, didn't take into account this line

QByteArray dummy(qMin(bytesToRead, qint64(SEEK_BUFFER_SIZE)), 0);

in KCompressionDevice::seek, i.e. sometimes the dummy buffer is not as big as we need to seek,
basically because we don't want to be allocating lots of memory.

The previous solution worked because never incremented the data pointer, that meant that the
internal QIODevice buffer might end in a bad state, so we fixed it but forgot about the case
where the dummy buffer we're using is not big enough and this was causing invalid memory writes.

To fix that now we have a while loop that reads as many times over the dummy buffer to seek
to the correct position.

Comes with an extended autottest, that has a big buffer and without this fix would crash.

Reviewers: apol

Reviewed By: apol

Subscribers: kde-frameworks-devel

Tags: Frameworks

Differential Revision: https://phabricator.kde.org/D21418

Details

Committed
aacidMay 27 2019, 7:19 AM
Reviewer
apol
Differential Revision
D21418: KCompressionDevice::seek: Fix previous fix ^_^
Parents
R243:d9878a684bad: Test reading and seeking in KCompressionDevice
Branches
Unknown
Tags
Unknown