diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-08-29 14:32:31 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-08-30 11:32:24 +0200 |
commit | 4099f7102a78f552eb85fadda7851db3c73b2d0f (patch) | |
tree | b1218ace71b2022eb93c0c87161aa0b43d2e0586 /emfio/source | |
parent | 9dc6fae25e6bf919d14b4bcb262a359893771ac0 (diff) |
ofz: MemorySanitizer: use-of-uninitialized-value
Change-Id: Ibeeef815afea9bee3cdf6b6de17de4f836b00351
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121223
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'emfio/source')
-rw-r--r-- | emfio/source/reader/emfreader.cxx | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index f3c1fffdfd77..6e6893c8afb2 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1734,10 +1734,25 @@ namespace emfio .WriteUInt16( 0 ) .WriteUInt16( 0 ) .WriteUInt32( cbBmiSrc + 14 ); + mpInputStream->Seek( nStart + offBmiSrc ); - mpInputStream->ReadBytes(pBuf + 14, cbBmiSrc); + char* pWritePos = pBuf + 14; + auto nRead = mpInputStream->ReadBytes(pWritePos, cbBmiSrc); + if (nRead != cbBmiSrc) + { + // zero remainder if short read + memset(pWritePos + nRead, 0, cbBmiSrc - nRead); + } + mpInputStream->Seek( nStart + offBitsSrc ); - mpInputStream->ReadBytes(pBuf + 14 + cbBmiSrc, cbBitsSrc); + pWritePos = pBuf + 14 + cbBmiSrc; + nRead = mpInputStream->ReadBytes(pWritePos, cbBitsSrc); + if (nRead != cbBitsSrc) + { + // zero remainder if short read + memset(pWritePos + nRead, 0, cbBitsSrc - nRead); + } + aTmp.Seek( 0 ); ReadDIB(aBitmap, aTmp, true); |