diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-11-13 14:28:43 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-11-13 14:30:47 +0900 |
commit | 8fa5a65792dc109791cbfbf5b8674cd9b65159dd (patch) | |
tree | b1c045465a98de9915a879dc5021b04025d156fc /starmath | |
parent | 5bff4b016c4b44f4123e0e6a4fd4c0c4dc0cfa2d (diff) |
Avoid possible memory leaks in case of exceptions
Change-Id: I411f8f800b7c7f23a7e581a36689f52ff99362c0
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/document.cxx | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index b8a37740f135..7f8115680737 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -94,6 +94,7 @@ #include <tools/diagnose_ex.h> #include "visitors.hxx" #include "accessibility.hxx" +#include <boost/scoped_ptr.hpp> using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; @@ -996,7 +997,7 @@ void SmDocShell::Execute(SfxRequest& rReq) pDev = &SM_MOD()->GetDefaultVirtualDev(); OSL_ENSURE (pDev, "device for font list missing" ); - SmFontTypeDialog *pFontTypeDialog = new SmFontTypeDialog( NULL, pDev ); + boost::scoped_ptr<SmFontTypeDialog> pFontTypeDialog(new SmFontTypeDialog( NULL, pDev )); SmFormat aOldFormat = GetFormat(); pFontTypeDialog->ReadFrom( aOldFormat ); @@ -1013,13 +1014,12 @@ void SmDocShell::Execute(SfxRequest& rReq) SetFormat( aNewFormat ); Repaint(); } - delete pFontTypeDialog; } break; case SID_FONTSIZE: { - SmFontSizeDialog *pFontSizeDialog = new SmFontSizeDialog(NULL); + boost::scoped_ptr<SmFontSizeDialog> pFontSizeDialog(new SmFontSizeDialog(NULL)); SmFormat aOldFormat = GetFormat(); pFontSizeDialog->ReadFrom( aOldFormat ); @@ -1037,13 +1037,12 @@ void SmDocShell::Execute(SfxRequest& rReq) SetFormat( aNewFormat ); Repaint(); } - delete pFontSizeDialog; } break; case SID_DISTANCE: { - SmDistanceDialog *pDistanceDialog = new SmDistanceDialog(NULL); + boost::scoped_ptr<SmDistanceDialog> pDistanceDialog(new SmDistanceDialog(NULL)); SmFormat aOldFormat = GetFormat(); pDistanceDialog->ReadFrom( aOldFormat ); @@ -1061,13 +1060,12 @@ void SmDocShell::Execute(SfxRequest& rReq) SetFormat( aNewFormat ); Repaint(); } - delete pDistanceDialog; } break; case SID_ALIGN: { - SmAlignDialog *pAlignDialog = new SmAlignDialog(NULL); + boost::scoped_ptr<SmAlignDialog> pAlignDialog(new SmAlignDialog(NULL)); SmFormat aOldFormat = GetFormat(); pAlignDialog->ReadFrom( aOldFormat ); @@ -1090,7 +1088,6 @@ void SmDocShell::Execute(SfxRequest& rReq) SetFormat( aNewFormat ); Repaint(); } - delete pAlignDialog; } break; |