emfio/source/reader/emfreader.cxx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
New commits: commit 5efd4c0a78633da563468f60c36c34a375584393 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Sep 2 10:31:56 2021 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Sep 3 16:11:13 2021 +0200 ofz: MemorySanitizer: use-of-uninitialized-value Change-Id: I6cd0e9b518bf6f40e0221fd2e9f3c5fb6199e14f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121574 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> 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); }