svtools/source/inc/hatchwindowfactory.hxx | 26 -------------------------- svtools/source/misc/ehdl.cxx | 20 ++++++++------------ svtools/source/misc/embedhlp.cxx | 10 ++++------ svtools/source/misc/imap.cxx | 12 +++--------- svtools/source/misc/transfer.cxx | 21 +++++++++------------ 5 files changed, 24 insertions(+), 65 deletions(-)
New commits: commit c414389e8790b1b044684627b3f4169e4559ca24 Author: Takeshi Abe <t...@fixedpoint.jp> Date: Sat Jul 5 20:57:50 2014 +0900 Avoid possible memory leaks in case of exceptions Change-Id: I46d49b515f5212a34612e80a82a3330a041b956c diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx index 7f91b93..924ead1 100644 --- a/svtools/source/misc/ehdl.cxx +++ b/svtools/source/misc/ehdl.cxx @@ -28,7 +28,7 @@ #include <svtools/svtresid.hxx> #include <svtools/svtools.hrc> #include <svtools/sfxecode.hxx> - +#include <boost/scoped_ptr.hpp> static sal_uInt16 aWndFunc( @@ -89,29 +89,28 @@ static sal_uInt16 aWndFunc( aErr = aErr.replaceAll("$(ACTION)", aAction); aErr = aErr.replaceAll("$(ERROR)", rErr); - MessBox* pBox; + boost::scoped_ptr<MessBox> pBox; switch ( nFlags & 0xf000 ) { case ERRCODE_MSG_ERROR: - pBox = new ErrorBox(pWin, eBits, aErr); + pBox.reset(new ErrorBox(pWin, eBits, aErr)); break; case ERRCODE_MSG_WARNING: - pBox = new WarningBox(pWin, eBits, aErr); + pBox.reset(new WarningBox(pWin, eBits, aErr)); break; case ERRCODE_MSG_INFO: - pBox = new InfoBox(pWin, aErr); + pBox.reset(new InfoBox(pWin, aErr)); break; case ERRCODE_MSG_QUERY: - pBox = new QueryBox(pWin, eBits, aErr); + pBox.reset(new QueryBox(pWin, eBits, aErr)); break; default: { SAL_WARN( "svtools.misc", "no MessBox type"); - pBox = NULL; return ERRCODE_BUTTON_OK; } } @@ -138,7 +137,6 @@ static sal_uInt16 aWndFunc( SAL_WARN( "svtools.misc", "Unknown MessBox return value" ); break; } - delete pBox; return nRet; } @@ -278,7 +276,7 @@ bool SfxErrorHandler::GetClassString(sal_uLong lClassId, OUString &rStr) const { bool bRet = false; - ResMgr* pResMgr = ResMgr::CreateResMgr("ofa", Application::GetSettings().GetUILanguageTag() ); + boost::scoped_ptr<ResMgr> pResMgr(ResMgr::CreateResMgr("ofa", Application::GetSettings().GetUILanguageTag() )); if( pResMgr ) { ResId aId(RID_ERRHDL, *pResMgr ); @@ -289,7 +287,6 @@ bool SfxErrorHandler::GetClassString(sal_uLong lClassId, OUString &rStr) const bRet = true; } } - delete pResMgr; return bRet; } @@ -306,7 +303,7 @@ bool SfxErrorHandler::GetMessageString( { bool bRet = false; - ResId *pResId= new ResId(nId, *pMgr); + boost::scoped_ptr<ResId> pResId(new ResId(nId, *pMgr)); ErrorResource_Impl aEr(*pResId, (sal_uInt16)lErrId); if(aEr) @@ -319,7 +316,6 @@ bool SfxErrorHandler::GetMessageString( bRet = true; } - delete pResId; return bRet; } diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index 9c1c51d..c1c3462 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -49,6 +49,7 @@ #include <cppuhelper/implbase4.hxx> #include <vcl/svapp.hxx> #include <osl/mutex.hxx> +#include <boost/scoped_ptr.hpp> using namespace com::sun::star; @@ -432,14 +433,13 @@ void EmbeddedObjectRef::GetReplacement( bool bUpdate ) return; } - SvStream* pGraphicStream = GetGraphicStream( bUpdate ); + boost::scoped_ptr<SvStream> pGraphicStream(GetGraphicStream( bUpdate )); if ( pGraphicStream ) { GraphicFilter& rGF = GraphicFilter::GetGraphicFilter(); if( mpImpl->pGraphic ) rGF.ImportGraphic( *mpImpl->pGraphic, OUString(), *pGraphicStream, GRFILTER_FORMAT_DONTKNOW ); mpImpl->mnGraphicVersion++; - delete pGraphicStream; } } @@ -531,7 +531,7 @@ void EmbeddedObjectRef::SetGraphicStream( const uno::Reference< io::XInputStream mpImpl->aMediaType = rMediaType; mpImpl->mnGraphicVersion++; - SvStream* pGraphicStream = ::utl::UcbStreamHelper::CreateStream( xInGrStream ); + boost::scoped_ptr<SvStream> pGraphicStream(::utl::UcbStreamHelper::CreateStream( xInGrStream )); if ( pGraphicStream ) { @@ -542,12 +542,10 @@ void EmbeddedObjectRef::SetGraphicStream( const uno::Reference< io::XInputStream if ( mpImpl->pContainer ) { pGraphicStream->Seek( 0 ); - uno::Reference< io::XInputStream > xInSeekGrStream = new ::utl::OSeekableInputStreamWrapper( pGraphicStream ); + uno::Reference< io::XInputStream > xInSeekGrStream = new ::utl::OSeekableInputStreamWrapper( pGraphicStream.get() ); mpImpl->pContainer->InsertGraphicStream( xInSeekGrStream, mpImpl->aPersistName, rMediaType ); } - - delete pGraphicStream; } mpImpl->bNeedUpdate = false; diff --git a/svtools/source/misc/imap.cxx b/svtools/source/misc/imap.cxx index df2fddc..f804c7f 100644 --- a/svtools/source/misc/imap.cxx +++ b/svtools/source/misc/imap.cxx @@ -32,7 +32,7 @@ #include <string.h> #include <math.h> - +#include <boost/scoped_ptr.hpp> #define SCALEPOINT(aPT,aFracX,aFracY) (aPT).X()=((aPT).X()*(aFracX).GetNumerator())/(aFracX).GetDenominator(); \ @@ -78,7 +78,6 @@ sal_uInt16 IMapObject::GetVersion() const void IMapObject::Write( SvStream& rOStm, const OUString& rBaseURL ) const { - IMapCompat* pCompat; const rtl_TextEncoding eEncoding = osl_getThreadTextEncoding(); rOStm.WriteUInt16( GetType() ); @@ -92,13 +91,11 @@ void IMapObject::Write( SvStream& rOStm, const OUString& rBaseURL ) const rOStm.WriteUChar( bActive ); write_uInt16_lenPrefixed_uInt8s_FromOUString(rOStm, aTarget, eEncoding); - pCompat = new IMapCompat( rOStm, STREAM_WRITE ); + boost::scoped_ptr<IMapCompat> pCompat(new IMapCompat( rOStm, STREAM_WRITE )); WriteIMapObject( rOStm ); aEventList.Write( rOStm ); // V4 write_uInt16_lenPrefixed_uInt8s_FromOUString(rOStm, aName, eEncoding); // V5 - - delete pCompat; } @@ -110,7 +107,6 @@ void IMapObject::Write( SvStream& rOStm, const OUString& rBaseURL ) const void IMapObject::Read( SvStream& rIStm, const OUString& rBaseURL ) { - IMapCompat* pCompat; rtl_TextEncoding nTextEncoding; // read on type and version @@ -124,7 +120,7 @@ void IMapObject::Read( SvStream& rIStm, const OUString& rBaseURL ) // make URL absolute aURL = URIHelper::SmartRel2Abs( INetURLObject(rBaseURL), aURL, URIHelper::GetMaybeFileHdl(), true, false, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_UNAMBIGUOUS ); - pCompat = new IMapCompat( rIStm, STREAM_READ ); + boost::scoped_ptr<IMapCompat> pCompat(new IMapCompat( rIStm, STREAM_READ )); ReadIMapObject( rIStm ); @@ -137,8 +133,6 @@ void IMapObject::Read( SvStream& rIStm, const OUString& rBaseURL ) if ( nReadVersion >= 0x0005 ) aName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rIStm, nTextEncoding); } - - delete pCompat; } bool IMapObject::IsEqual( const IMapObject& rEqObj ) diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx index 5a916b6..9cc21e7 100644 --- a/svtools/source/misc/transfer.cxx +++ b/svtools/source/misc/transfer.cxx @@ -59,7 +59,7 @@ #include <vcl/dibtools.hxx> #include <vcl/pngread.hxx> #include <vcl/pngwrite.hxx> - +#include <boost/scoped_ptr.hpp> // - Namespaces - @@ -351,11 +351,11 @@ Any SAL_CALL TransferableHelper::getTransferData2( const DataFlavor& rFlavor, co if( maAny >>= aSeq ) { - SvMemoryStream* pSrcStm = new SvMemoryStream( (char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_WRITE | STREAM_TRUNC ); + boost::scoped_ptr<SvMemoryStream> pSrcStm(new SvMemoryStream( (char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_WRITE | STREAM_TRUNC )); GDIMetaFile aMtf; ReadGDIMetaFile( *pSrcStm, aMtf ); - delete pSrcStm; + pSrcStm.reset(); Graphic aGraphic( aMtf ); SvMemoryStream aDstStm( 65535, 65535 ); @@ -381,11 +381,11 @@ Any SAL_CALL TransferableHelper::getTransferData2( const DataFlavor& rFlavor, co if( maAny >>= aSeq ) { - SvMemoryStream* pSrcStm = new SvMemoryStream( (char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_WRITE | STREAM_TRUNC ); + boost::scoped_ptr<SvMemoryStream> pSrcStm(new SvMemoryStream( (char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_WRITE | STREAM_TRUNC )); GDIMetaFile aMtf; ReadGDIMetaFile( *pSrcStm, aMtf ); - delete pSrcStm; + pSrcStm.reset(); SvMemoryStream aDstStm( 65535, 65535 ); @@ -2017,22 +2017,21 @@ bool TransferableDataHelper::GetINetBookmark( const ::com::sun::star::datatransf if( ( aDesc.getLength() > 4 ) && aDesc.copy(aDesc.getLength() - 4).equalsIgnoreAsciiCase(".URL") ) { - SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( INetURLObject( OStringToOUString(aDesc, eTextEncoding) ).GetMainURL( INetURLObject::NO_DECODE ), - STREAM_STD_READ ); + boost::scoped_ptr<SvStream> pStream(::utl::UcbStreamHelper::CreateStream( INetURLObject( OStringToOUString(aDesc, eTextEncoding) ).GetMainURL( INetURLObject::NO_DECODE ), + STREAM_STD_READ )); if( !pStream || pStream->GetError() ) { DataFlavor aFileContentFlavor; aSeq.realloc( 0 ); - delete pStream; - pStream = NULL; + pStream.reset(); if (SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_FILECONTENT, aFileContentFlavor)) { aSeq = GetSequence(aFileContentFlavor, OUString()); if (aSeq.getLength()) - pStream = new SvMemoryStream( (sal_Char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_STD_READ ); + pStream.reset(new SvMemoryStream( (sal_Char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_STD_READ )); } } @@ -2053,8 +2052,6 @@ bool TransferableDataHelper::GetINetBookmark( const ::com::sun::star::datatransf break; } } - - delete pStream; } } } commit 6a9d51b24bb73ad1536e223ee03cd0d3214709ef Author: Takeshi Abe <t...@fixedpoint.jp> Date: Sat Jul 5 20:26:40 2014 +0900 Drop an empty header Change-Id: I34904af6da8f37459ef96071caa53230ad02a8e7 diff --git a/svtools/source/inc/hatchwindowfactory.hxx b/svtools/source/inc/hatchwindowfactory.hxx deleted file mode 100644 index 2875aaf..0000000 --- a/svtools/source/inc/hatchwindowfactory.hxx +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SVTOOLS_SOURCE_INC_HATCHWINDOWFACTORY_HXX -#define INCLUDED_SVTOOLS_SOURCE_INC_HATCHWINDOWFACTORY_HXX - - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits