xmloff/source/chart/SchXMLExport.cxx |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

New commits:
commit 684d79906ff8e84dc2872b33e65c7d8dc303bddf
Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk>
Date:   Sun Jun 8 07:31:19 2014 +0200

    avoid memory leak and invalid documents
    
    See e.g. fdo54757-1.xlsx exported to ods.
    
    Change-Id: I81fb9a18519c5770b52dfb8131211e440ad9682f

diff --git a/xmloff/source/chart/SchXMLExport.cxx 
b/xmloff/source/chart/SchXMLExport.cxx
index cfd0c1f..ab62903 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<SvXMLElementExport> 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 <chart:chart> 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<SvXMLElementExport> 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 )
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to