Kaydet (Commit) 1839223f authored tarafından Caolán McNamara's avatar Caolán McNamara Kaydeden (comit) Andras Timar

ensure loop ends eventually

Change-Id: I318385286fcc27ffb2d938237d83e793564d2525
(cherry picked from commit c02e7987)
Reviewed-on: https://gerrit.libreoffice.org/17214Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst a3c72032
...@@ -886,36 +886,41 @@ void CCIDecompressor::FillBits(sal_uInt8 * pTarget, sal_uInt16 nTargetBits, ...@@ -886,36 +886,41 @@ void CCIDecompressor::FillBits(sal_uInt8 * pTarget, sal_uInt16 nTargetBits,
} }
} }
sal_uInt16 CCIDecompressor::CountBits(const sal_uInt8 * pData, sal_uInt16 nDataSizeBits, sal_uInt16 CCIDecompressor::CountBits(const sal_uInt8 * pData, sal_uInt16 nDataSizeBits,
sal_uInt16 nBitPos, sal_uInt8 nBlackOrWhite) sal_uInt16 nBitPos, sal_uInt8 nBlackOrWhite)
{ {
sal_uInt16 nPos,nLo;
sal_uInt8 nData;
// here the number of bits belonging together is being counted // here the number of bits belonging together is being counted
// which all have the color nBlackOrWhite (0xff oder 0x00) // which all have the color nBlackOrWhite (0xff oder 0x00)
// from the position nBitPos on // from the position nBitPos on
sal_uInt16 nPos = nBitPos;
nPos=nBitPos; for (;;)
for (;;) { {
if (nPos>=nDataSizeBits) { if (nPos>=nDataSizeBits)
{
nPos=nDataSizeBits; nPos=nDataSizeBits;
break; break;
} }
nData=pData[nPos>>3]; sal_uInt8 nData = pData[nPos>>3];
nLo=nPos & 7; sal_uInt16 nLo = nPos & 7;
if ( nLo==0 && nData==nBlackOrWhite) nPos+=8; if (nLo==0 && nData==nBlackOrWhite)
else { {
if ( ((nData^nBlackOrWhite) & (0x80 >> nLo))!=0) break; //fail on overflow attempt
nPos++; if (nPos > SAL_MAX_UINT16-8)
return 0;
nPos+=8;
}
else
{
if ( ((nData^nBlackOrWhite) & (0x80 >> nLo))!=0)
break;
++nPos;
} }
} }
if (nPos<=nBitPos) return 0; if (nPos<=nBitPos)
else return nPos-nBitPos; return 0;
return nPos-nBitPos;
} }
void CCIDecompressor::Read1DScanlineData(sal_uInt8 * pTarget, sal_uInt16 nTargetBits) void CCIDecompressor::Read1DScanlineData(sal_uInt8 * pTarget, sal_uInt16 nTargetBits)
{ {
sal_uInt16 nCode,nCodeBits,nDataBits,nTgtFreeByteBits; sal_uInt16 nCode,nCodeBits,nDataBits,nTgtFreeByteBits;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment