summaryrefslogtreecommitdiff
path: root/sw/source/uibase/wrtsh
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-06-21 22:54:28 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-06-21 23:01:21 +0900
commitc260abe39e0063a2e5ba4e0d22ff8a5ccd468c23 (patch)
treeff61e582558ee872d3a550cf5b91afa84f9dc5d6 /sw/source/uibase/wrtsh
parentf8cd68bad6728a5402401a3b7235f7d5d22c0ce1 (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: I27a0c3639c346720df471ffa3940783565c47f7d
Diffstat (limited to 'sw/source/uibase/wrtsh')
-rw-r--r--sw/source/uibase/wrtsh/wrtsh2.cxx10
1 files changed, 5 insertions, 5 deletions
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 1abb58135cb4..36d2321ed5fc 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -78,7 +78,7 @@ void SwWrtShell::Insert(SwField &rFld)
StartUndo(UNDO_INSERT, &aRewriter);
bool bDeleted = false;
- const SwPaM* pAnnotationTextRange = NULL;
+ boost::scoped_ptr<SwPaM> pAnnotationTextRange;
if ( HasSelection() )
{
if ( rFld.GetTyp()->Which() == RES_POSTITFLD )
@@ -96,13 +96,13 @@ void SwWrtShell::Insert(SwField &rFld)
EndPara();
}
const SwPosition rEndPos( *GetCurrentShellCursor().GetPoint() );
- pAnnotationTextRange = new SwPaM( rStartPos, rEndPos );
+ pAnnotationTextRange.reset(new SwPaM( rStartPos, rEndPos ));
}
else
{
NormalizePam( false );
const SwPaM& rCurrPaM = GetCurrentShellCursor();
- pAnnotationTextRange = new SwPaM( *rCurrPaM.GetPoint(), *rCurrPaM.GetMark() );
+ pAnnotationTextRange.reset(new SwPaM( *rCurrPaM.GetPoint(), *rCurrPaM.GetMark() ));
ClearMark();
}
}
@@ -114,14 +114,14 @@ void SwWrtShell::Insert(SwField &rFld)
SwEditShell::Insert2(rFld, bDeleted);
- if ( pAnnotationTextRange != NULL )
+ if ( pAnnotationTextRange )
{
if ( GetDoc() != NULL )
{
IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess();
pMarksAccess->makeAnnotationMark( *pAnnotationTextRange, ::rtl::OUString() );
}
- delete pAnnotationTextRange;
+ pAnnotationTextRange.reset();
}
EndUndo();