summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-01-18 15:58:58 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-01-21 09:38:01 +0100
commit3a001a588c43cf8c2c3f6cb6a6796cc1bf8e2683 (patch)
tree4b471df42d2b327c6ccaf1419f2f65b7f819206e
parent113536e974d7ebbbc484b0ef40406f9b4d14e511 (diff)
Fix -Werror=maybe-uninitialized
...as emitted by at least GCC 8.2 with --enable-optimized: > In file included from vcl/source/gdi/pngread.cxx:27: > include/vcl/pngread.hxx: In member function ‘bool vcl::PNGReaderImpl::ReadNextChunk()’: > include/vcl/pngread.hxx:49:12: error: ‘aDummyChunk.vcl::PNGReader::ChunkData::nType’ may be used uninitialized in this function [-Werror=maybe-uninitialized] > struct ChunkData > ^~~~~~~~~ The immediately relevant part is initializing sal_uInt32 nType = 0; in the ChunkData ctor, but while at it, also make the Read*Int32 calls in PNGReaderImpl::ReadNextChunk more robust. Change-Id: Id6ad10a4382a8d063fd70c7bac595c3693475ca3 Reviewed-on: https://gerrit.libreoffice.org/66619 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--include/vcl/pngread.hxx2
-rw-r--r--vcl/source/gdi/pngread.cxx2
2 files changed, 3 insertions, 1 deletions
diff --git a/include/vcl/pngread.hxx b/include/vcl/pngread.hxx
index 8992709b3349..31592d9f17ac 100644
--- a/include/vcl/pngread.hxx
+++ b/include/vcl/pngread.hxx
@@ -48,7 +48,7 @@ public:
// retrieve every chunk that resides inside the PNG
struct ChunkData
{
- sal_uInt32 nType;
+ sal_uInt32 nType = 0;
std::vector<sal_uInt8> aData;
};
const std::vector<ChunkData>& GetChunks() const;
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 78195d5e7c46..b5ac9e430596 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -273,6 +273,8 @@ bool PNGReaderImpl::ReadNextChunk()
PNGReader::ChunkData& rChunkData = *maChunkIter;
// read the chunk header
+ mnChunkLen = 0;
+ mnChunkType = 0;
mrPNGStream.ReadInt32( mnChunkLen ).ReadUInt32( mnChunkType );
rChunkData.nType = mnChunkType;