summaryrefslogtreecommitdiff
path: root/emfio/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-08-30 12:24:16 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-08-30 20:22:59 +0200
commita0b5731dd6e8be9d61c5da2225512970f47a7c72 (patch)
tree188f04b3cdb3e6fea8997b486286f15195fc27f7 /emfio/source
parent91b0024965908c692bea40f47c58ea9d1bf8a596 (diff)
ofz: MemorySanitizer: use-of-uninitialized-value
Change-Id: Iccdfb92beae8d79863d1bca3dc44c1a13bf30a67 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121299 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'emfio/source')
-rw-r--r--emfio/source/reader/emfreader.cxx17
1 files changed, 15 insertions, 2 deletions
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index 6e6893c8afb2..dc154228ac21 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -1543,7 +1543,13 @@ namespace emfio
// copy DIBInfoHeader from source (cbBmiSrc bytes)
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);
+ }
if (bReadAlpha)
{
@@ -1555,7 +1561,14 @@ namespace emfio
// copy bitmap data from source (offBitsSrc bytes)
mpInputStream->Seek( nStart + offBitsSrc );
- mpInputStream->ReadBytes(pBuf + 14 + nDeltaToDIB5HeaderSize + cbBmiSrc, cbBitsSrc);
+ pWritePos = pBuf + 14 + nDeltaToDIB5HeaderSize + cbBmiSrc;
+ nRead = mpInputStream->ReadBytes(pWritePos, cbBitsSrc);
+ if (nRead != cbBitsSrc)
+ {
+ // zero remainder if short read
+ memset(pWritePos + nRead, 0, cbBitsSrc - nRead);
+ }
+
aTmp.Seek( 0 );
// prepare to read and fill BitmapEx