diff options
-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); |