summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-10-03 12:32:26 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-10-03 13:09:25 +0100
commit301058b7eeb31360ee3ffef76523cbd1d3e4fc62 (patch)
tree09b621122afa695d52c959c6d522a68d3296eeb1 /sw/source
parent17d42fdfdf1428b1e48dfab9f71a759b8c767ec4 (diff)
CID#705757 leaks on early return
also CID#705756, CID#705755 and CID#705754 Change-Id: Ie02bb10049dc680199dfa6c218b6b1f92927e4a4
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/xml/xmlimpit.cxx66
1 files changed, 41 insertions, 25 deletions
diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx
index 6d57f456249d..5e1dabf46562 100644
--- a/sw/source/filter/xml/xmlimpit.cxx
+++ b/sw/source/filter/xml/xmlimpit.cxx
@@ -222,6 +222,34 @@ SvXMLImportItemMapper::finished(SfxItemSet &, SvXMLUnitConverter const&) const
// nothing to do here
}
+struct BoxHolder : private boost::noncopyable
+{
+ SvxBorderLine* pTop;
+ SvxBorderLine* pBottom;
+ SvxBorderLine* pLeft;
+ SvxBorderLine* pRight;
+
+ BoxHolder(SvxBoxItem* pBox)
+ {
+ pTop = pBox->GetTop() == NULL ?
+ NULL : new SvxBorderLine( *pBox->GetTop() );
+ pBottom = pBox->GetBottom() == NULL ?
+ NULL : new SvxBorderLine( *pBox->GetBottom() );
+ pLeft = pBox->GetLeft() == NULL ?
+ NULL : new SvxBorderLine( *pBox->GetLeft() );
+ pRight = pBox->GetRight() == NULL ?
+ NULL : new SvxBorderLine( *pBox->GetRight() );
+ }
+
+ ~BoxHolder()
+ {
+ delete pTop;
+ delete pBottom;
+ delete pLeft;
+ delete pRight;
+ }
+};
+
// put an XML-string value into an item
@@ -410,14 +438,7 @@ bool SvXMLImportItemMapper::PutXMLValue(
OSL_ENSURE( pBox != NULL, "Wrong WHich-ID" );
/** copy SvxBorderLines */
- SvxBorderLine* pTop = pBox->GetTop() == NULL ?
- NULL : new SvxBorderLine( *pBox->GetTop() );
- SvxBorderLine* pBottom = pBox->GetBottom() == NULL ?
- NULL : new SvxBorderLine( *pBox->GetBottom() );
- SvxBorderLine* pLeft = pBox->GetLeft() == NULL ?
- NULL : new SvxBorderLine( *pBox->GetLeft() );
- SvxBorderLine* pRight = pBox->GetRight() == NULL ?
- NULL : new SvxBorderLine( *pBox->GetRight() );
+ BoxHolder aBoxes(pBox);
sal_Int32 nTemp;
@@ -471,25 +492,25 @@ bool SvXMLImportItemMapper::PutXMLValue(
return false;
if( TOP_BORDER == nMemberId || ALL_BORDER == nMemberId )
- sw_frmitems_setXMLBorder( pTop,
+ sw_frmitems_setXMLBorder( aBoxes.pTop,
bHasStyle, nStyle,
bHasWidth, nWidth, nNamedWidth,
bHasColor, aColor );
if( BOTTOM_BORDER == nMemberId || ALL_BORDER == nMemberId )
- sw_frmitems_setXMLBorder( pBottom,
+ sw_frmitems_setXMLBorder( aBoxes.pBottom,
bHasStyle, nStyle,
bHasWidth, nWidth, nNamedWidth,
bHasColor, aColor );
if( LEFT_BORDER == nMemberId || ALL_BORDER == nMemberId )
- sw_frmitems_setXMLBorder( pLeft,
+ sw_frmitems_setXMLBorder( aBoxes.pLeft,
bHasStyle, nStyle,
bHasWidth, nWidth, nNamedWidth,
bHasColor, aColor );
if( RIGHT_BORDER == nMemberId || ALL_BORDER == nMemberId )
- sw_frmitems_setXMLBorder( pRight,
+ sw_frmitems_setXMLBorder( aBoxes.pRight,
bHasStyle, nStyle,
bHasWidth, nWidth, nNamedWidth,
bHasColor, aColor );
@@ -529,28 +550,28 @@ bool SvXMLImportItemMapper::PutXMLValue(
if( TOP_BORDER_LINE_WIDTH == nMemberId ||
ALL_BORDER_LINE_WIDTH == nMemberId )
- sw_frmitems_setXMLBorder( pTop, nWidth,
+ sw_frmitems_setXMLBorder( aBoxes.pTop, nWidth,
static_cast< sal_uInt16 >( nOutWidth ),
static_cast< sal_uInt16 >( nInWidth ),
static_cast< sal_uInt16 >( nDistance ) );
if( BOTTOM_BORDER_LINE_WIDTH == nMemberId ||
ALL_BORDER_LINE_WIDTH == nMemberId )
- sw_frmitems_setXMLBorder( pBottom, nWidth,
+ sw_frmitems_setXMLBorder( aBoxes.pBottom, nWidth,
static_cast< sal_uInt16 >( nOutWidth ),
static_cast< sal_uInt16 >( nInWidth ),
static_cast< sal_uInt16 >( nDistance ) );
if( LEFT_BORDER_LINE_WIDTH == nMemberId ||
ALL_BORDER_LINE_WIDTH == nMemberId )
- sw_frmitems_setXMLBorder( pLeft, nWidth,
+ sw_frmitems_setXMLBorder( aBoxes.pLeft, nWidth,
static_cast< sal_uInt16 >( nOutWidth ),
static_cast< sal_uInt16 >( nInWidth ),
static_cast< sal_uInt16 >( nDistance ) );
if( RIGHT_BORDER_LINE_WIDTH == nMemberId ||
ALL_BORDER_LINE_WIDTH == nMemberId )
- sw_frmitems_setXMLBorder( pRight, nWidth,
+ sw_frmitems_setXMLBorder( aBoxes.pRight, nWidth,
static_cast< sal_uInt16 >( nOutWidth ),
static_cast< sal_uInt16 >( nInWidth ),
static_cast< sal_uInt16 >( nDistance ) );
@@ -558,15 +579,10 @@ bool SvXMLImportItemMapper::PutXMLValue(
break;
}
- pBox->SetLine( pTop, BOX_LINE_TOP );
- pBox->SetLine( pBottom, BOX_LINE_BOTTOM );
- pBox->SetLine( pLeft, BOX_LINE_LEFT );
- pBox->SetLine( pRight, BOX_LINE_RIGHT );
-
- delete pTop;
- delete pBottom;
- delete pLeft;
- delete pRight;
+ pBox->SetLine( aBoxes.pTop, BOX_LINE_TOP );
+ pBox->SetLine( aBoxes.pBottom, BOX_LINE_BOTTOM );
+ pBox->SetLine( aBoxes.pLeft, BOX_LINE_LEFT );
+ pBox->SetLine( aBoxes.pRight, BOX_LINE_RIGHT );
bOk = true;
}