check that AddToTable can be done validly
Change-Id: I0ee69279e3bb1d9871feba17b908b8307f0ec5b4
This commit is contained in:
parent
b9623def05
commit
43b39d3e47
2 changed files with 16 additions and 6 deletions
|
@ -107,7 +107,7 @@ HPBYTE GIFLZWDecompressor::DecompressBlock( HPBYTE pSrc, sal_uInt8 cBufSize,
|
|||
return pTarget;
|
||||
}
|
||||
|
||||
void GIFLZWDecompressor::AddToTable( sal_uInt16 nPrevCode, sal_uInt16 nCodeFirstData )
|
||||
bool GIFLZWDecompressor::AddToTable( sal_uInt16 nPrevCode, sal_uInt16 nCodeFirstData )
|
||||
{
|
||||
GIFLZWTableEntry* pE;
|
||||
|
||||
|
@ -116,12 +116,16 @@ void GIFLZWDecompressor::AddToTable( sal_uInt16 nPrevCode, sal_uInt16 nCodeFirst
|
|||
pE = pTable + nTableSize;
|
||||
pE->pPrev = pTable + nPrevCode;
|
||||
pE->pFirst = pE->pPrev->pFirst;
|
||||
pE->nData = pTable[ nCodeFirstData ].pFirst->nData;
|
||||
GIFLZWTableEntry *pEntry = pTable[nCodeFirstData].pFirst;
|
||||
if (!pEntry)
|
||||
return false;
|
||||
pE->nData = pEntry->nData;
|
||||
nTableSize++;
|
||||
|
||||
if ( ( nTableSize == (sal_uInt16) (1 << nCodeSize) ) && ( nTableSize < 4096 ) )
|
||||
nCodeSize++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GIFLZWDecompressor::ProcessOneCode()
|
||||
|
@ -153,17 +157,23 @@ bool GIFLZWDecompressor::ProcessOneCode()
|
|||
|
||||
if ( nCode < nClearCode )
|
||||
{
|
||||
bool bOk = true;
|
||||
if ( nOldCode != 0xffff )
|
||||
AddToTable( nOldCode, nCode );
|
||||
bOk = AddToTable(nOldCode, nCode);
|
||||
if (!bOk)
|
||||
return false;
|
||||
}
|
||||
else if ( ( nCode > nEOICode ) && ( nCode <= nTableSize ) )
|
||||
{
|
||||
if ( nOldCode != 0xffff )
|
||||
{
|
||||
bool bOk;
|
||||
if ( nCode == nTableSize )
|
||||
AddToTable( nOldCode, nOldCode );
|
||||
bOk = AddToTable( nOldCode, nOldCode );
|
||||
else
|
||||
AddToTable( nOldCode, nCode );
|
||||
bOk = AddToTable( nOldCode, nCode );
|
||||
if (!bOk)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -43,7 +43,7 @@ class GIFLZWDecompressor
|
|||
sal_uInt8 nBlockBufSize;
|
||||
sal_uInt8 nBlockBufPos;
|
||||
|
||||
void AddToTable(sal_uInt16 nPrevCode, sal_uInt16 nCodeFirstData);
|
||||
bool AddToTable(sal_uInt16 nPrevCode, sal_uInt16 nCodeFirstData);
|
||||
bool ProcessOneCode();
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue