Fix memory leak

Change-Id: I9e271c3b7ff49d33f4f6f3f8c50b70ac5ce1541e
This commit is contained in:
Stephan Bergmann
2016-01-12 10:04:47 +01:00
parent 70d2673ba0
commit b497655a48
2 changed files with 7 additions and 8 deletions

View File

@@ -122,6 +122,7 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <set> #include <set>
#include <utility>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <tools/time.hxx> #include <tools/time.hxx>
#include <memory> #include <memory>
@@ -1219,12 +1220,12 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
} }
if (nRowCount > 0) if (nRowCount > 0)
{ {
sal_uInt32* pTableArry = new sal_uInt32[ nRowCount + 2 ]; std::unique_ptr<sal_uInt32[]> pTableArry(new sal_uInt32[ nRowCount + 2 ]);
pTableArry[ 0 ] = nTableProperties; pTableArry[ 0 ] = nTableProperties;
pTableArry[ 1 ] = nRowCount; pTableArry[ 1 ] = nRowCount;
for ( i = 0; i < nRowCount; i++ ) for ( i = 0; i < nRowCount; i++ )
rSt.ReadUInt32( pTableArry[ i + 2 ] ); rSt.ReadUInt32( pTableArry[ i + 2 ] );
rData.pTableRowProperties = pTableArry; rData.pTableRowProperties = std::move(pTableArry);
} }
} }
} }
@@ -2862,12 +2863,12 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
Rectangle aEmpty; Rectangle aEmpty;
aShapeHd.SeekToBegOfRecord( rStCtrl ); aShapeHd.SeekToBegOfRecord( rStCtrl );
sal_Int32 nShapeId; sal_Int32 nShapeId;
aProcessData.pTableRowProperties = nullptr; aProcessData.pTableRowProperties.reset();
SdrObject* pObj = ImportObj( rStCtrl, static_cast<void*>(&aProcessData), aEmpty, aEmpty, 0, &nShapeId ); SdrObject* pObj = ImportObj( rStCtrl, static_cast<void*>(&aProcessData), aEmpty, aEmpty, 0, &nShapeId );
if ( pObj ) if ( pObj )
{ {
if ( aProcessData.pTableRowProperties ) if ( aProcessData.pTableRowProperties )
pObj = CreateTable( pObj, aProcessData.pTableRowProperties, aProcessData.rPersistEntry.pSolverContainer ); pObj = CreateTable( pObj, aProcessData.pTableRowProperties.get(), aProcessData.rPersistEntry.pSolverContainer );
pRet->NbcInsertObject( pObj ); pRet->NbcInsertObject( pObj );

View File

@@ -508,13 +508,11 @@ struct ProcessData
PptSlidePersistEntry& rPersistEntry; PptSlidePersistEntry& rPersistEntry;
SdPageCapsule pPage; SdPageCapsule pPage;
::std::vector< SdrObject* > aBackgroundColoredObjects; ::std::vector< SdrObject* > aBackgroundColoredObjects;
sal_uInt32* pTableRowProperties; std::unique_ptr<sal_uInt32[]> pTableRowProperties;
ProcessData( PptSlidePersistEntry& rP, SdPageCapsule pP ) : ProcessData( PptSlidePersistEntry& rP, SdPageCapsule pP ) :
rPersistEntry ( rP ), rPersistEntry ( rP ),
pPage ( pP ), pPage ( pP ) {};
pTableRowProperties ( nullptr ) {};
~ProcessData() { delete[] pTableRowProperties; };
}; };