diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-01-08 10:33:51 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-01-08 11:22:09 +0000 |
commit | 350824178333b58948dbc3826ad759f10b0f026e (patch) | |
tree | 4bd8abf09fb8d4051df9c12075d25e3711ae8b74 /vcl | |
parent | 8eb880a04d17c888c2c986426e935e02ae309e7a (diff) |
valgrind, zero out the trailing unused alignment bytes
as seen with fdo55736-1.docx
Change-Id: Ie1dec06282a600e600f606a3b4ddd814613b0108
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/dibtools.cxx | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx index d226edc23cd9..3f940afac0a5 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -1102,17 +1102,18 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess& rAcc, BitmapReadAccess* const long nWidth(rAcc.Width()); const long nHeight(rAcc.Height()); boost::scoped_array<sal_uInt8> pBuf(new sal_uInt8[ nAlignedWidth ]); - sal_uInt8* pTmp(0); - sal_uInt8 cTmp(0); - switch( nBitCount ) { case( 1 ): { + //valgrind, zero out the trailing unused alignment bytes + size_t nUnusedBytes = nAlignedWidth - ((nWidth+7) / 8); + memset(pBuf.get() + nAlignedWidth - nUnusedBytes, 0, nUnusedBytes); + for( long nY = nHeight - 1; nY >= 0L; nY-- ) { - pTmp = pBuf.get(); - cTmp = 0; + sal_uInt8* pTmp = pBuf.get(); + sal_uInt8 cTmp = 0; for( long nX = 0L, nShift = 8L; nX < nWidth; nX++ ) { @@ -1134,10 +1135,14 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess& rAcc, BitmapReadAccess* case( 4 ): { + //valgrind, zero out the trailing unused alignment bytes + size_t nUnusedBytes = nAlignedWidth - ((nWidth+1) / 2); + memset(pBuf.get() + nAlignedWidth - nUnusedBytes, 0, nUnusedBytes); + for( long nY = nHeight - 1; nY >= 0L; nY-- ) { - pTmp = pBuf.get(); - cTmp = 0; + sal_uInt8* pTmp = pBuf.get(); + sal_uInt8 cTmp = 0; for( long nX = 0L, nShift = 2L; nX < nWidth; nX++ ) { @@ -1160,7 +1165,7 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess& rAcc, BitmapReadAccess* { for( long nY = nHeight - 1; nY >= 0L; nY-- ) { - pTmp = pBuf.get(); + sal_uInt8* pTmp = pBuf.get(); for( long nX = 0L; nX < nWidth; nX++ ) *pTmp++ = rAcc.GetPixelIndex( nY, nX ); @@ -1180,7 +1185,7 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess& rAcc, BitmapReadAccess* for( long nY = nHeight - 1; nY >= 0L; nY-- ) { - pTmp = pBuf.get(); + sal_uInt8* pTmp = pBuf.get(); for( long nX = 0L; nX < nWidth; nX++ ) { |