summaryrefslogtreecommitdiff
path: root/emfio
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-09-02 10:31:56 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-09-03 16:11:13 +0200
commit5efd4c0a78633da563468f60c36c34a375584393 (patch)
treee2f819ea360b271d92db5b95b324299180079d7f /emfio
parentaa9e05236b73067e34d34d9861fc394ba854399b (diff)
ofz: MemorySanitizer: use-of-uninitialized-value
Change-Id: I6cd0e9b518bf6f40e0221fd2e9f3c5fb6199e14f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121574 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'emfio')
-rw-r--r--emfio/source/reader/emfreader.cxx19
1 files changed, 17 insertions, 2 deletions
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index 758a3220d517..68ff6752b69d 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -2112,10 +2112,25 @@ namespace emfio
.WriteUInt16( 0 )
.WriteUInt16( 0 )
.WriteUInt32( cbBmi + 14 );
+
mpInputStream->Seek( nStart + offBmi );
- mpInputStream->ReadBytes(pBuf + 14, cbBmi);
+ char* pWritePos = pBuf + 14;
+ auto nRead = mpInputStream->ReadBytes(pWritePos, cbBmi);
+ if (nRead != cbBmi)
+ {
+ // zero remainder if short read
+ memset(pWritePos + nRead, 0, cbBmi - nRead);
+ }
+
mpInputStream->Seek( nStart + offBits );
- mpInputStream->ReadBytes(pBuf + 14 + cbBmi, cbBits);
+ pWritePos = pBuf + 14 + cbBmi;
+ nRead = mpInputStream->ReadBytes(pWritePos, cbBits);
+ if (nRead != cbBits)
+ {
+ // zero remainder if short read
+ memset(pWritePos + nRead, 0, cbBits - nRead);
+ }
+
aTmp.Seek( 0 );
ReadDIB(aBitmap, aTmp, true);
}