Kaydet (Commit) 3a001a58 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 113536e9
......@@ -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;
......
......@@ -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;
......
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