From 684d79906ff8e84dc2872b33e65c7d8dc303bddf Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sun, 8 Jun 2014 07:31:19 +0200 Subject: avoid memory leak and invalid documents See e.g. fdo54757-1.xlsx exported to ods. Change-Id: I81fb9a18519c5770b52dfb8131211e440ad9682f --- xmloff/source/chart/SchXMLExport.cxx | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'xmloff/source') diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index cfd0c1f5c4ff..ab6290336b7b 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -1210,7 +1210,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >& } // chart element - SvXMLElementExport* pElChart = 0; + boost::scoped_ptr pElChart; // get property states for autostyles if( mxExpPropMapper.is()) @@ -1283,7 +1283,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >& AddAutoStyleAttribute( aPropertyStates ); //element - pElChart = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_CHART, true, true ); + pElChart.reset(new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_CHART, true, true )); } else // autostyles { @@ -1540,10 +1540,6 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >& // #85929# always export table, otherwise clipboard may lose data exportTable(); } - - // close element - if( pElChart ) - delete pElChart; } static void lcl_exportComplexLabel( const Sequence< uno::Any >& rComplexLabel, SvXMLExport& rExport ) @@ -1866,7 +1862,7 @@ void SchXMLExportHelper_Impl::exportPlotArea( // plot-area element - SvXMLElementExport* pElPlotArea = 0; + boost::scoped_ptr pElPlotArea; // get property states for autostyles xPropSet = Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ); if( xPropSet.is()) @@ -1956,7 +1952,7 @@ void SchXMLExportHelper_Impl::exportPlotArea( } // plot-area element - pElPlotArea = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_PLOT_AREA, true, true ); + pElPlotArea.reset(new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_PLOT_AREA, true, true )); //inner position rectangle element exportCoordinateRegion( xDiagram ); @@ -2111,9 +2107,6 @@ void SchXMLExportHelper_Impl::exportPlotArea( } } } - - if( pElPlotArea ) - delete pElPlotArea; } void SchXMLExportHelper_Impl::exportCoordinateRegion( const uno::Reference< chart::XDiagram >& xDiagram ) -- cgit