cid#707834 silence Uninitialized scalar field

and

cid#1474340 silence Uninitialized scalar field

Change-Id: Ib5d12595bfcd2eaf5b26ce333d5ea8328fdeb2aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112880
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara 2021-03-22 10:53:37 +00:00
parent 1534c12544
commit 4566bcbf03
3 changed files with 23 additions and 21 deletions

View file

@ -24,6 +24,7 @@
LZWDecompressor::LZWDecompressor()
: pIStream(nullptr)
, aTable{{}}
, nTableSize(0)
, bEOIFound(false)
, bInvert(false)
@ -36,9 +37,9 @@ LZWDecompressor::LZWDecompressor()
{
for (sal_uInt16 i=0; i<MAX_TABLE_SIZE; i++)
{
pTable[i].nPrevCode=0;
pTable[i].nDataCount=1;
pTable[i].nData=static_cast<sal_uInt8>(i);
aTable[i].nPrevCode=0;
aTable[i].nDataCount=1;
aTable[i].nData=static_cast<sal_uInt8>(i);
}
}
@ -156,7 +157,7 @@ void LZWDecompressor::AddToTable(sal_uInt16 nPrevCode, sal_uInt16 nCodeFirstData
}
unsigned char aSeenIndexes[MAX_TABLE_SIZE] = {0};
while (pTable[nCodeFirstData].nDataCount>1)
while (aTable[nCodeFirstData].nDataCount>1)
{
if (aSeenIndexes[nCodeFirstData])
{
@ -165,12 +166,12 @@ void LZWDecompressor::AddToTable(sal_uInt16 nPrevCode, sal_uInt16 nCodeFirstData
return;
}
aSeenIndexes[nCodeFirstData] = 1;
nCodeFirstData=pTable[nCodeFirstData].nPrevCode;
nCodeFirstData=aTable[nCodeFirstData].nPrevCode;
}
pTable[nTableSize].nPrevCode=nPrevCode;
pTable[nTableSize].nDataCount=pTable[nPrevCode].nDataCount+1;
pTable[nTableSize].nData=pTable[nCodeFirstData].nData;
aTable[nTableSize].nPrevCode=nPrevCode;
aTable[nTableSize].nDataCount=aTable[nPrevCode].nDataCount+1;
aTable[nTableSize].nData=aTable[nCodeFirstData].nData;
nTableSize++;
}
@ -204,12 +205,12 @@ void LZWDecompressor::DecompressSome()
nOldCode=nCode;
nOutBufDataLen=pTable[nCode].nDataCount;
nOutBufDataLen=aTable[nCode].nDataCount;
pOutBufData=pOutBuf.data()+nOutBufDataLen;
for (i=0; i<nOutBufDataLen; i++)
{
*(--pOutBufData)=pTable[nCode].nData;
nCode=pTable[nCode].nPrevCode;
*(--pOutBufData)=aTable[nCode].nData;
nCode=aTable[nCode].nPrevCode;
}
}

View file

@ -53,7 +53,7 @@ private:
SvStream* pIStream;
std::array<LZWTableEntry, MAX_TABLE_SIZE> pTable;
std::array<LZWTableEntry, MAX_TABLE_SIZE> aTable;
sal_uInt16 nTableSize;
bool bEOIFound, bInvert, bFirst;

View file

@ -299,7 +299,7 @@ private:
};
std::array<LZWCTreeNode, 4096>
mpTable; // LZW compression data
maTable; // LZW compression data
LZWCTreeNode* mpPrefix; // the compression is as same as the TIFF compression
static constexpr sal_uInt16 gnDataSize = 8;
static constexpr sal_uInt16 gnClearCode = 1 << gnDataSize;
@ -323,6 +323,7 @@ public:
LZWEncoder::LZWEncoder(osl::File* pOutputFile) :
Ascii85Encoder (pOutputFile),
maTable{{}},
mpPrefix(nullptr),
mnTableSize(gnEOICode + 1),
mnCodeSize(gnDataSize + 1),
@ -331,10 +332,10 @@ LZWEncoder::LZWEncoder(osl::File* pOutputFile) :
{
for (sal_uInt32 i = 0; i < 4096; i++)
{
mpTable[i].mpBrother = nullptr;
mpTable[i].mpFirstChild = nullptr;
mpTable[i].mnCode = i;
mpTable[i].mnValue = static_cast<sal_uInt8>(mpTable[i].mnCode);
maTable[i].mpBrother = nullptr;
maTable[i].mpFirstChild = nullptr;
maTable[i].mnCode = i;
maTable[i].mnValue = static_cast<sal_uInt8>(maTable[i].mnCode);
}
WriteBits( gnClearCode, mnCodeSize );
@ -372,7 +373,7 @@ LZWEncoder::EncodeByte (sal_uInt8 nByte )
if (!mpPrefix)
{
mpPrefix = mpTable.data() + nByte;
mpPrefix = maTable.data() + nByte;
}
else
{
@ -396,7 +397,7 @@ LZWEncoder::EncodeByte (sal_uInt8 nByte )
WriteBits (gnClearCode, mnCodeSize);
for (i = 0; i < gnClearCode; i++)
mpTable[i].mpFirstChild = nullptr;
maTable[i].mpFirstChild = nullptr;
mnCodeSize = gnDataSize + 1;
mnTableSize = gnEOICode + 1;
@ -406,14 +407,14 @@ LZWEncoder::EncodeByte (sal_uInt8 nByte )
if(mnTableSize == static_cast<sal_uInt16>((1 << mnCodeSize) - 1))
mnCodeSize++;
p = mpTable.data() + (mnTableSize++);
p = maTable.data() + (mnTableSize++);
p->mpBrother = mpPrefix->mpFirstChild;
mpPrefix->mpFirstChild = p;
p->mnValue = nV;
p->mpFirstChild = nullptr;
}
mpPrefix = mpTable.data() + nV;
mpPrefix = maTable.data() + nV;
}
}
}