D21418: KCompressionDevice::seek: Fix previous fix ^_^
Albert Astals Cid
noreply at phabricator.kde.org
Sun May 26 18:51:44 BST 2019
aacid created this revision.
Herald added a project: Frameworks.
Herald added a subscriber: kde-frameworks-devel.
aacid requested review of this revision.
REVISION 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.
REPOSITORY
R243 KArchive
BRANCH
master
REVISION DETAIL
https://phabricator.kde.org/D21418
AFFECTED FILES
autotests/kcompressiondevicetest.cpp
autotests/kcompressiondevicetest.h
src/kcompressiondevice.cpp
src/kcompressiondevice_p.h
To: aacid
Cc: kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190526/29297852/attachment-0001.html>
More information about the Kde-frameworks-devel
mailing list