Kaydet (Commit) e3bd2ee4 authored tarafından Takeshi Abe's avatar Takeshi Abe

Avoid possible resource leaks by boost::scoped_array

Change-Id: Ie20fc857f19f74aaccb546f9bfa11a7a657d3e8a
üst 8b533d84
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "svx/flagsdef.hxx" #include "svx/flagsdef.hxx"
#include <vector> #include <vector>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <boost/scoped_array.hpp>
using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Reference;
using ::com::sun::star::lang::XServiceInfo; using ::com::sun::star::lang::XServiceInfo;
...@@ -736,10 +737,10 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet& rCoreAttrs ) ...@@ -736,10 +737,10 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet& rCoreAttrs )
if ( nDelCount > 0 ) if ( nDelCount > 0 )
{ {
sal_uInt32* pDelArr = new sal_uInt32[nDelCount]; boost::scoped_array<sal_uInt32> pDelArr(new sal_uInt32[nDelCount]);
pNumFmtShell->GetUpdateData( pDelArr, nDelCount ); pNumFmtShell->GetUpdateData( pDelArr.get(), nDelCount );
pNumItem->SetDelFormatArray( pDelArr, nDelCount ); pNumItem->SetDelFormatArray( pDelArr.get(), nDelCount );
if(bNumItemFlag==sal_True) if(bNumItemFlag==sal_True)
{ {
...@@ -755,7 +756,6 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet& rCoreAttrs ) ...@@ -755,7 +756,6 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet& rCoreAttrs )
if ( pDocSh ) if ( pDocSh )
pDocSh->PutItem( *pNumItem ); pDocSh->PutItem( *pNumItem );
} }
delete [] pDelArr;
} }
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include <svtools/htmlcfg.hxx> #include <svtools/htmlcfg.hxx>
#include <connectivity/formattedcolumnvalue.hxx> #include <connectivity/formattedcolumnvalue.hxx>
#include <unotools/syslocale.hxx> #include <unotools/syslocale.hxx>
#include <boost/scoped_array.hpp>
using namespace dbaui; using namespace dbaui;
using namespace dbtools; using namespace dbtools;
...@@ -453,7 +454,7 @@ sal_Bool ORTFImportExport::Write() ...@@ -453,7 +454,7 @@ sal_Bool ORTFImportExport::Write()
m_pStream->WriteChar( '{' ).WriteCharPtr( SAL_NEWLINE_STRING ); m_pStream->WriteChar( '{' ).WriteCharPtr( SAL_NEWLINE_STRING );
m_pStream->WriteCharPtr( aTRRH ); m_pStream->WriteCharPtr( aTRRH );
OString* pHorzChar = new OString[nCount]; boost::scoped_array<OString> pHorzChar(new OString[nCount]);
for ( sal_Int32 i=1; i <= nCount; ++i ) for ( sal_Int32 i=1; i <= nCount; ++i )
{ {
...@@ -527,7 +528,7 @@ sal_Bool ORTFImportExport::Write() ...@@ -527,7 +528,7 @@ sal_Bool ORTFImportExport::Write()
} }
if ( bContinue ) if ( bContinue )
appendRow( pHorzChar, nCount, k, kk ); appendRow( pHorzChar.get(), nCount, k, kk );
} }
} }
else else
...@@ -535,10 +536,9 @@ sal_Bool ORTFImportExport::Write() ...@@ -535,10 +536,9 @@ sal_Bool ORTFImportExport::Write()
m_xResultSet->beforeFirst(); // set back before the first row m_xResultSet->beforeFirst(); // set back before the first row
while(m_xResultSet->next()) while(m_xResultSet->next())
{ {
appendRow(pHorzChar,nCount,k,kk); appendRow(pHorzChar.get(),nCount,k,kk);
} }
} }
delete [] pHorzChar;
} }
m_pStream->WriteChar( '}' ).WriteCharPtr( SAL_NEWLINE_STRING ); m_pStream->WriteChar( '}' ).WriteCharPtr( SAL_NEWLINE_STRING );
...@@ -826,10 +826,10 @@ void OHTMLImportExport::WriteTables() ...@@ -826,10 +826,10 @@ void OHTMLImportExport::WriteTables()
if(m_xObject.is()) if(m_xObject.is())
{ {
sal_Int32* pFormat = new sal_Int32[aNames.getLength()]; boost::scoped_array<sal_Int32> pFormat(new sal_Int32[aNames.getLength()]);
const char **pHorJustify = new const char*[aNames.getLength()]; boost::scoped_array<const char *> pHorJustify(new const char*[aNames.getLength()]);
sal_Int32 *pColWidth = new sal_Int32[aNames.getLength()]; boost::scoped_array<sal_Int32> pColWidth(new sal_Int32[aNames.getLength()]);
sal_Int32 nHeight = 0; sal_Int32 nHeight = 0;
m_xObject->getPropertyValue(PROPERTY_ROW_HEIGHT) >>= nHeight; m_xObject->getPropertyValue(PROPERTY_ROW_HEIGHT) >>= nHeight;
...@@ -911,10 +911,6 @@ void OHTMLImportExport::WriteTables() ...@@ -911,10 +911,6 @@ void OHTMLImportExport::WriteTables()
++j; ++j;
TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow ); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
} }
delete [] pFormat;
delete [] pHorJustify;
delete [] pColWidth;
} }
else else
{ {
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <osl/file.hxx> #include <osl/file.hxx>
#include <rtl/process.h> #include <rtl/process.h>
#include "tools/getprocessworkingdir.hxx" #include "tools/getprocessworkingdir.hxx"
#include <boost/scoped_array.hpp>
using namespace desktop; using namespace desktop;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
...@@ -261,11 +262,11 @@ OUString CreateMD5FromString( const OUString& aMsg ) ...@@ -261,11 +262,11 @@ OUString CreateMD5FromString( const OUString& aMsg )
const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr(); const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr();
sal_uInt32 nSize = ( aMsg.getLength() * sizeof( sal_Unicode )); sal_uInt32 nSize = ( aMsg.getLength() * sizeof( sal_Unicode ));
sal_uInt32 nMD5KeyLen = rtl_digest_queryLength( handle ); sal_uInt32 nMD5KeyLen = rtl_digest_queryLength( handle );
sal_uInt8* pMD5KeyBuffer = new sal_uInt8[ nMD5KeyLen ]; boost::scoped_array<sal_uInt8> pMD5KeyBuffer(new sal_uInt8[ nMD5KeyLen ]);
rtl_digest_init( handle, pData, nSize ); rtl_digest_init( handle, pData, nSize );
rtl_digest_update( handle, pData, nSize ); rtl_digest_update( handle, pData, nSize );
rtl_digest_get( handle, pMD5KeyBuffer, nMD5KeyLen ); rtl_digest_get( handle, pMD5KeyBuffer.get(), nMD5KeyLen );
rtl_digest_destroy( handle ); rtl_digest_destroy( handle );
// Create hex-value string from the MD5 value to keep the string size minimal // Create hex-value string from the MD5 value to keep the string size minimal
...@@ -273,7 +274,6 @@ OUString CreateMD5FromString( const OUString& aMsg ) ...@@ -273,7 +274,6 @@ OUString CreateMD5FromString( const OUString& aMsg )
for ( sal_uInt32 i = 0; i < nMD5KeyLen; i++ ) for ( sal_uInt32 i = 0; i < nMD5KeyLen; i++ )
aBuffer.append( (sal_Int32)pMD5KeyBuffer[i], 16 ); aBuffer.append( (sal_Int32)pMD5KeyBuffer[i], 16 );
delete [] pMD5KeyBuffer;
return aBuffer.makeStringAndClear(); return aBuffer.makeStringAndClear();
} }
......
...@@ -73,6 +73,7 @@ using namespace std; ...@@ -73,6 +73,7 @@ using namespace std;
#include "editeng.hrc" #include "editeng.hrc"
#include <editeng/eerdll.hxx> #include <editeng/eerdll.hxx>
#include <editeng/numitem.hxx> #include <editeng/numitem.hxx>
#include <boost/scoped_array.hpp>
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::beans; using namespace ::com::sun::star::beans;
...@@ -1333,7 +1334,7 @@ namespace accessibility ...@@ -1333,7 +1334,7 @@ namespace accessibility
// build sorted index array // build sorted index array
sal_Int32 nLength = aRes.getLength(); sal_Int32 nLength = aRes.getLength();
const beans::PropertyValue* pPairs = aRes.getConstArray(); const beans::PropertyValue* pPairs = aRes.getConstArray();
sal_Int32* pIndices = new sal_Int32[nLength]; boost::scoped_array<sal_Int32> pIndices(new sal_Int32[nLength]);
sal_Int32 i = 0; sal_Int32 i = 0;
for( i = 0; i < nLength; i++ ) for( i = 0; i < nLength; i++ )
pIndices[i] = i; pIndices[i] = i;
...@@ -1345,7 +1346,6 @@ namespace accessibility ...@@ -1345,7 +1346,6 @@ namespace accessibility
{ {
pNewValues[i] = pPairs[pIndices[i]]; pNewValues[i] = pPairs[pIndices[i]];
} }
delete[] pIndices;
return aNewValues; return aNewValues;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment