diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-01-17 20:53:19 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-01-18 11:34:10 +0000 |
commit | da5b1d6d1612ccb01ca480d53cc68be5d13a01ec (patch) | |
tree | 5809d3c3e3f1bba19c8e9fc82b8c22e633e0c34f /sd/source | |
parent | d50c0a09a58b5c24a2a484e83004c286fe873205 (diff) |
cppcheck: doubleFree
Change-Id: I371db988044264b6b1ff95bd7c683d1485430fe8
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/func/fuinsfil.cxx | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index b768b077d23c..f47970d3f6b2 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -258,20 +258,20 @@ void FuInsertFile::DoExecute( SfxRequest& rReq ) mpDocSh->SetWaitCursor( true ); - SfxMedium* pMedium = new SfxMedium( aFile, StreamMode::READ | StreamMode::NOCREATE ); + std::unique_ptr<SfxMedium> xMedium(new SfxMedium(aFile, StreamMode::READ | StreamMode::NOCREATE)); const SfxFilter* pFilter = nullptr; - SfxGetpApp()->GetFilterMatcher().GuessFilter( *pMedium, &pFilter ); + SfxGetpApp()->GetFilterMatcher().GuessFilter(*xMedium, &pFilter); bool bDrawMode = mpViewShell && dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr; bool bInserted = false; if( pFilter ) { - pMedium->SetFilter( pFilter ); + xMedium->SetFilter( pFilter ); aFilterName = pFilter->GetFilterName(); - if( pMedium->IsStorage() || ( pMedium->GetInStream() && SotStorage::IsStorageFile( pMedium->GetInStream() ) ) ) + if( xMedium->IsStorage() || ( xMedium->GetInStream() && SotStorage::IsStorageFile( xMedium->GetInStream() ) ) ) { if ( pFilter->GetServiceName() == "com.sun.star.presentation.PresentationDocument" || pFilter->GetServiceName() == "com.sun.star.drawing.DrawingDocument" ) @@ -279,11 +279,11 @@ void FuInsertFile::DoExecute( SfxRequest& rReq ) // Draw, Impress or PowerPoint document // the ownership of the Medium is transferred if( bDrawMode ) - InsSDDinDrMode( pMedium ); + InsSDDinDrMode(xMedium.release()); else - InsSDDinOlMode( pMedium ); + InsSDDinOlMode(xMedium.release()); - // don't delete Medium here, ownership of pMedium has changed in this case + // ownership of pMedium has changed in this case bInserted = true; } } @@ -302,12 +302,12 @@ void FuInsertFile::DoExecute( SfxRequest& rReq ) if( bFound ) { if( bDrawMode ) - InsTextOrRTFinDrMode(pMedium); + InsTextOrRTFinDrMode(xMedium.get()); else - InsTextOrRTFinOlMode(pMedium); + InsTextOrRTFinOlMode(xMedium.get()); bInserted = true; - delete pMedium; + xMedium.reset(); } } } @@ -318,7 +318,6 @@ void FuInsertFile::DoExecute( SfxRequest& rReq ) { ScopedVclPtrInstance< MessageDialog > aErrorBox(mpWindow, SD_RESSTR( STR_READ_DATA_ERROR)); aErrorBox->Execute(); - delete pMedium; } } |