From 4566bcbf03c1b7b0c1ce3a83fee1d195f0ff7059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 22 Mar 2021 10:53:37 +0000 Subject: [PATCH] cid#707834 silence Uninitialized scalar field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- vcl/source/filter/itiff/lzwdecom.cxx | 23 ++++++++++++----------- vcl/source/filter/itiff/lzwdecom.hxx | 2 +- vcl/unx/generic/print/bitmap_gfx.cxx | 19 ++++++++++--------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/vcl/source/filter/itiff/lzwdecom.cxx b/vcl/source/filter/itiff/lzwdecom.cxx index 15784321b92e..14a7e276f4ee 100644 --- a/vcl/source/filter/itiff/lzwdecom.cxx +++ b/vcl/source/filter/itiff/lzwdecom.cxx @@ -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(i); + aTable[i].nPrevCode=0; + aTable[i].nDataCount=1; + aTable[i].nData=static_cast(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 pTable; + std::array aTable; sal_uInt16 nTableSize; bool bEOIFound, bInvert, bFirst; diff --git a/vcl/unx/generic/print/bitmap_gfx.cxx b/vcl/unx/generic/print/bitmap_gfx.cxx index 4ddce0214190..830561b9677f 100644 --- a/vcl/unx/generic/print/bitmap_gfx.cxx +++ b/vcl/unx/generic/print/bitmap_gfx.cxx @@ -299,7 +299,7 @@ private: }; std::array - 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(mpTable[i].mnCode); + maTable[i].mpBrother = nullptr; + maTable[i].mpFirstChild = nullptr; + maTable[i].mnCode = i; + maTable[i].mnValue = static_cast(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((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; } } }