include/vcl/salbtype.hxx | 29 ------------------ vcl/source/filter/wmf/winwmf.cxx | 38 ++++++++++++++++++++++-- writerperfect/source/common/DirectoryStream.cxx | 3 + 3 files changed, 38 insertions(+), 32 deletions(-)
New commits: commit ea2537d5ea64f4f238fa434dbc7cf53263afe78c Author: Stephan Bergmann <sberg...@redhat.com> Date: Thu Jun 5 18:31:54 2014 +0200 Fix memory leak Change-Id: I74001eb033abd7ceb10da60ea707f876d9f22c08 diff --git a/writerperfect/source/common/DirectoryStream.cxx b/writerperfect/source/common/DirectoryStream.cxx index a352290..cfc423b 100644 --- a/writerperfect/source/common/DirectoryStream.cxx +++ b/writerperfect/source/common/DirectoryStream.cxx @@ -129,7 +129,10 @@ DirectoryStream *DirectoryStream::createForParent(const com::sun::star::uno::Ref { pDir = new writerperfect::DirectoryStream(xDirContent); if (!pDir->isStructured()) + { + delete pDir; pDir = 0; + } } } commit a1d7ed235738609ce8c0ecedff075f9d0e531034 Author: Stephan Bergmann <sberg...@redhat.com> Date: Thu Jun 5 18:31:22 2014 +0200 Avoid undefined mis-aligned memory access Change-Id: Ie79a0810cf00217fe2b9ffd34e21aeb7b2299c0d diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx index 7829c11..ccdbfbe 100644 --- a/include/vcl/salbtype.hxx +++ b/include/vcl/salbtype.hxx @@ -22,7 +22,6 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> -#include <osl/endian.h> #include <tools/debug.hxx> #include <vcl/salgtype.hxx> #include <tools/color.hxx> @@ -782,11 +781,7 @@ inline void ColorMask::SetColorFor8Bit( const BitmapColor& rColor, HPBYTE pPixel inline void ColorMask::GetColorFor16BitMSB( BitmapColor& rColor, ConstHPBYTE pPixel ) const { -#ifdef OSL_BIGENDIAN - const sal_uInt32 nVal = *(sal_uInt16*) pPixel; -#else const sal_uInt32 nVal = pPixel[ 1 ] | ( (sal_uInt32) pPixel[ 0 ] << 8UL ); -#endif MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); } @@ -797,23 +792,15 @@ inline void ColorMask::SetColorFor16BitMSB( const BitmapColor& rColor, HPBYTE pP { const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift ); -#ifdef OSL_BIGENDIAN - *(sal_uInt16*) pPixel = nVal; -#else pPixel[ 0 ] = (sal_uInt8)(nVal >> 8U); pPixel[ 1 ] = (sal_uInt8) nVal; -#endif } inline void ColorMask::GetColorFor16BitLSB( BitmapColor& rColor, ConstHPBYTE pPixel ) const { -#ifdef OSL_BIGENDIAN const sal_uInt32 nVal = pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ); -#else - const sal_uInt32 nVal = *(sal_uInt16*) pPixel; -#endif MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); } @@ -824,12 +811,8 @@ inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, HPBYTE pP { const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift ); -#ifdef OSL_BIGENDIAN pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8)(nVal >> 8U); -#else - *(sal_uInt16*) pPixel = nVal; -#endif } @@ -853,12 +836,8 @@ inline void ColorMask::SetColorFor24Bit( const BitmapColor& rColor, HPBYTE pPixe inline void ColorMask::GetColorFor32Bit( BitmapColor& rColor, ConstHPBYTE pPixel ) const { -#ifdef OSL_BIGENDIAN const sal_uInt32 nVal = (sal_uInt32) pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ) | ( (sal_uInt32) pPixel[ 2 ] << 16UL ) | ( (sal_uInt32) pPixel[ 3 ] << 24UL ); -#else - const sal_uInt32 nVal = *(sal_uInt32*) pPixel; -#endif MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); } @@ -867,12 +846,8 @@ inline void ColorMask::GetColorFor32Bit( BitmapColor& rColor, ConstHPBYTE pPixel inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8& rAlpha, ConstHPBYTE pPixel ) const { -#ifdef OSL_BIGENDIAN const sal_uInt32 nVal = (sal_uInt32) pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ) | ( (sal_uInt32) pPixel[ 2 ] << 16UL ) | ( (sal_uInt32) pPixel[ 3 ] << 24UL ); -#else - const sal_uInt32 nVal = *(sal_uInt32*) pPixel; -#endif rAlpha = (sal_uInt8)(nVal >> 24); MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); @@ -882,13 +857,9 @@ inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8& inline void ColorMask::SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const { -#ifdef OSL_BIGENDIAN const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift ); pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL ); pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL ); pPixel[ 3 ] = (sal_uInt8) ( nVal >> 24UL ); -#else - *(sal_uInt32*) pPixel = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift ); -#endif } #endif // INCLUDED_VCL_SALBTYPE_HXX commit f3758b71d980540b4a9cb6086fab04e23be13b00 Author: Stephan Bergmann <sberg...@redhat.com> Date: Thu Jun 5 18:30:26 2014 +0200 If no bounds can be determined, assume some reasonable defaults (instead of the twisted huge values with which aBound got initialized) Change-Id: Ic6fe08639287eb7b5a0520aef8d2a0d43d61c035 diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx index 8079263..54163f7 100644 --- a/vcl/source/filter/wmf/winwmf.cxx +++ b/vcl/source/filter/wmf/winwmf.cxx @@ -1090,6 +1090,8 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc ) } } +static const long aMaxWidth = 1024; + bool WMFReader::ReadHeader() { sal_Size nStrmPos = pWMF->Tell(); @@ -1162,7 +1164,6 @@ bool WMFReader::ReadHeader() // The image size is not known so normalize the calculated bounds so that the // resulting image is not too big - const long aMaxWidth = 1024; const double fMaxWidth = static_cast<double>(aMaxWidth); if (aPlaceableBound.GetWidth() > aMaxWidth) { @@ -1355,6 +1356,7 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) aBound.Top() = RECT_MAX; aBound.Right() = RECT_MIN; aBound.Bottom() = RECT_MIN; + bool bBoundsDetermined = false; sal_uInt32 nPos = pStm->Tell(); sal_uInt32 nEnd = pStm->Seek( STREAM_SEEK_TO_END ); @@ -1431,6 +1433,7 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) case W_META_MOVETO: case W_META_LINETO: GetWinExtMax( ReadYX(), aBound, nMapMode ); + bBoundsDetermined = true; break; case W_META_RECTANGLE: @@ -1438,11 +1441,13 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) case W_META_EXCLUDECLIPRECT : case W_META_ELLIPSE: GetWinExtMax( ReadRectangle(), aBound, nMapMode ); + bBoundsDetermined = true; break; case W_META_ROUNDRECT: ReadYXExt(); // size GetWinExtMax( ReadRectangle(), aBound, nMapMode ); + bBoundsDetermined = true; break; case W_META_ARC: @@ -1451,6 +1456,7 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) ReadYX(); // end ReadYX(); // start GetWinExtMax( ReadRectangle(), aBound, nMapMode ); + bBoundsDetermined = true; break; case W_META_POLYGON: @@ -1458,7 +1464,10 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) sal_uInt16 nPoints; pStm->ReadUInt16( nPoints ); for(sal_uInt16 i = 0; i < nPoints; i++ ) + { GetWinExtMax( ReadPoint(), aBound, nMapMode ); + bBoundsDetermined = true; + } } break; @@ -1491,7 +1500,10 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) } for (sal_uInt16 i = 0; i < nPoints; i++ ) + { GetWinExtMax( ReadPoint(), aBound, nMapMode ); + bBoundsDetermined = true; + } bRecordOk &= pStm->good(); @@ -1509,7 +1521,10 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) sal_uInt16 nPoints; pStm->ReadUInt16( nPoints ); for(sal_uInt16 i = 0; i < nPoints; i++ ) + { GetWinExtMax( ReadPoint(), aBound, nMapMode ); + bBoundsDetermined = true; + } } break; @@ -1517,6 +1532,7 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) { ReadColor(); GetWinExtMax( ReadYX(), aBound, nMapMode ); + bBoundsDetermined = true; } break; @@ -1529,6 +1545,7 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) { pStm->SeekRel( ( nLength + 1 ) &~ 1 ); GetWinExtMax( ReadYX(), aBound, nMapMode ); + bBoundsDetermined = true; } } break; @@ -1542,7 +1559,10 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) pStm->ReadUInt16( nLen ).ReadUInt16( nOptions ); // todo: we also have to take care of the text width if( nLen ) + { GetWinExtMax( aPosition, aBound, nMapMode ); + bBoundsDetermined = true; + } } break; case W_META_BITBLT: @@ -1578,6 +1598,7 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) { Rectangle aDestRect( ReadYX(), aDestSize ); GetWinExtMax( aDestRect, aBound, nMapMode ); + bBoundsDetermined = true; } } } @@ -1589,6 +1610,7 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) pStm->ReadUInt32( nROP ); Size aSize = ReadYXExt(); GetWinExtMax( Rectangle( ReadYX(), aSize ), aBound, nMapMode ); + bBoundsDetermined = true; } break; } @@ -1624,10 +1646,20 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm ) << " t: " << rPlaceableBound.Left() << " l: " << rPlaceableBound.Top() << " b: " << rPlaceableBound.Right() << " r: " << rPlaceableBound.Bottom()); } - else + else if (bBoundsDetermined) { rPlaceableBound = aBound; - SAL_INFO("vcl.wmf", "Detemined dimension " + SAL_INFO("vcl.wmf", "Determined dimension " + << " t: " << rPlaceableBound.Left() << " l: " << rPlaceableBound.Top() + << " b: " << rPlaceableBound.Right() << " r: " << rPlaceableBound.Bottom()); + } + else + { + rPlaceableBound.Left() = 0; + rPlaceableBound.Top() = 0; + rPlaceableBound.Right() = aMaxWidth; + rPlaceableBound.Bottom() = aMaxWidth; + SAL_INFO("vcl.wmf", "Default dimension " << " t: " << rPlaceableBound.Left() << " l: " << rPlaceableBound.Top() << " b: " << rPlaceableBound.Right() << " r: " << rPlaceableBound.Bottom()); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits