[Libreoffice-commits] core.git: vcl/source
Caolán McNamara
caolanm at redhat.com
Tue Feb 13 14:02:07 UTC 2018
vcl/source/gdi/dibtools.cxx | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
New commits:
commit 6cb383da1be97f010552d08fbd631e14547aec41
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Feb 13 11:57:50 2018 +0000
ofz#5428 Timeout
Change-Id: I8fe05cbaaf2f39723e76100bcdb928c859d712d8
Reviewed-on: https://gerrit.libreoffice.org/49639
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index ba41e6132a58..325f1e68d670 100644
--- a/vcl/source/gdi/dibtools.cxx
+++ b/vcl/source/gdi/dibtools.cxx
@@ -827,14 +827,21 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uL
rIStm.ReadUInt32( nCodedSize ).ReadUInt32( nUncodedSize ).ReadUInt32( aHeader.nCompression );
if (nCodedSize > rIStm.remainingSize())
nCodedSize = sal_uInt32(rIStm.remainingSize());
- size_t nSizeInc(4 * rIStm.remainingSize());
+
+ pMemStm.reset(new SvMemoryStream);
+ // There may be bytes left over or the codec might read more than
+ // necessary. So to preserve the correctness of the source stream copy
+ // the encoded block
+ pMemStm->WriteStream(rIStm, nCodedSize);
+ pMemStm->Seek(0);
+
+ size_t nSizeInc(4 * pMemStm->remainingSize());
if (nUncodedSize < nSizeInc)
nSizeInc = nUncodedSize;
if (nSizeInc > 0)
{
// decode buffer
- const sal_uLong nCodedPos = rIStm.Tell();
ZCodec aCodec;
aCodec.BeginCompression();
aData.resize(nSizeInc);
@@ -845,7 +852,7 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uL
const size_t nToRead(std::min<size_t>(nUncodedSize - nDataPos, aData.size() - nDataPos));
assert(nToRead > 0);
assert(!aData.empty());
- const long nRead = aCodec.Read(rIStm, aData.data() + nDataPos, sal_uInt32(nToRead));
+ const long nRead = aCodec.Read(*pMemStm, aData.data() + nDataPos, sal_uInt32(nToRead));
if (nRead > 0)
{
nDataPos += static_cast<unsigned long>(nRead);
@@ -863,9 +870,6 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uL
// set the real uncoded size
nUncodedSize = sal_uInt32(aData.size());
aCodec.EndCompression();
-
- // Seek behind the encoded block. There might have been bytes left or the codec might have read more than necessary.
- rIStm.Seek(nCodedSize + nCodedPos);
}
if (aData.empty())
More information about the Libreoffice-commits
mailing list