[Libreoffice-commits] core.git: oox/inc oox/source

Caolán McNamara caolanm at redhat.com
Thu Apr 30 08:03:23 PDT 2015


 oox/inc/drawingml/table/tableproperties.hxx    |    2 +-
 oox/source/drawingml/table/tableproperties.cxx |   16 ++++++----------
 2 files changed, 7 insertions(+), 11 deletions(-)

New commits:
commit 2bb444ecb10436b640c1dc35e85cdcb512c8dff6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Apr 30 16:00:41 2015 +0100

    see if a re-org will silence coverity#1272392 Resource leak
    
    Change-Id: I65c20f75c4086dc5167c6fa41b0171f07c1419bb

diff --git a/oox/inc/drawingml/table/tableproperties.hxx b/oox/inc/drawingml/table/tableproperties.hxx
index ea03f75..eb3ba78 100644
--- a/oox/inc/drawingml/table/tableproperties.hxx
+++ b/oox/inc/drawingml/table/tableproperties.hxx
@@ -57,7 +57,7 @@ public:
 
 private:
 
-    const TableStyle&                   getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase, bool &isCreateTabStyle);
+    const TableStyle&                   getUsedTableStyle(const ::oox::core::XmlFilterBase& rFilterBase, TableStyle*& rTableStyleToDelete);
 
     OUString                            maStyleId;              // either StyleId is available
     boost::shared_ptr< TableStyle >     mpTableStyle;           // or the complete TableStyle
diff --git a/oox/source/drawingml/table/tableproperties.cxx b/oox/source/drawingml/table/tableproperties.cxx
index 393095b..380fcfb 100644
--- a/oox/source/drawingml/table/tableproperties.cxx
+++ b/oox/source/drawingml/table/tableproperties.cxx
@@ -221,7 +221,7 @@ TableStyle* CreateTableStyle(const OUString& styleId)
     return pTableStyle;
 }
 
-const TableStyle& TableProperties::getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase, bool &isCreateTabStyle )
+const TableStyle& TableProperties::getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase, TableStyle*& rTableStyleToDelete )
 {
     ::oox::core::XmlFilterBase& rBase( const_cast< ::oox::core::XmlFilterBase& >( rFilterBase ) );
 
@@ -245,8 +245,8 @@ const TableStyle& TableProperties::getUsedTableStyle( const ::oox::core::XmlFilt
         //if the pptx just has table style id, but no table style content, we will create the table style ourselves
         if (!pTableStyle)
         {
-            pTableStyle = CreateTableStyle(aStyleId);
-            isCreateTabStyle = (pTableStyle != NULL);
+            rTableStyleToDelete = CreateTableStyle(aStyleId);
+            pTableStyle = rTableStyleToDelete;
         }
     }
 
@@ -265,8 +265,8 @@ void TableProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBa
     CreateTableColumns( xColumnRowRange->getColumns(), mvTableGrid );
     CreateTableRows( xColumnRowRange->getRows(), mvTableRows );
 
-    bool bOwnTblStyle = false;
-    const TableStyle& rTableStyle( getUsedTableStyle( rFilterBase, bOwnTblStyle ) );
+    TableStyle* pTableStyleToDelete = NULL;
+    const TableStyle& rTableStyle( getUsedTableStyle( rFilterBase, pTableStyleToDelete ) );
     sal_Int32 nRow = 0;
     const std::vector< TableRow >::const_iterator aTableRowEnd( mvTableRows.end() );
     for (std::vector< TableRow >::iterator aTableRowIter( mvTableRows.begin() );
@@ -291,11 +291,7 @@ void TableProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBa
         }
     }
 
-    if(bOwnTblStyle)
-    {
-        TableStyle* pTableStyle = const_cast<TableStyle*>(&rTableStyle);
-        delete pTableStyle;
-    }
+    delete pTableStyleToDelete;
 }
 
 } } }


More information about the Libreoffice-commits mailing list