[Libreoffice-commits] core.git: sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Sun Mar 13 20:21:25 UTC 2016


 sc/source/filter/excel/tokstack.cxx |   19 ++++++++++++++-----
 sc/source/filter/inc/tokstack.hxx   |    1 +
 2 files changed, 15 insertions(+), 5 deletions(-)

New commits:
commit 3887e8439a6928d2f608315f7050d012be65d208
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Mar 13 19:15:16 2016 +0100

    fix memory leak in array xls import
    
    The ScMatrix instances are leaked because there is no DecRef called on
    them when we Reset the TokenPool.
    
    Change-Id: Ie5e1a10c6be94b45df784c04f6db744928f213ff
    Reviewed-on: https://gerrit.libreoffice.org/23194
    Reviewed-by: Kohei Yoshida <libreoffice at kohei.us>
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/filter/excel/tokstack.cxx b/sc/source/filter/excel/tokstack.cxx
index 1bafcfbc..31e8995 100644
--- a/sc/source/filter/excel/tokstack.cxx
+++ b/sc/source/filter/excel/tokstack.cxx
@@ -126,11 +126,7 @@ TokenPool::~TokenPool()
         delete ppP_Nlf[ n ];
     delete[] ppP_Nlf;
 
-    for( n = 0 ; n < nP_Matrix ; n++ )
-    {
-        if( ppP_Matrix[ n ] )
-            ppP_Matrix[ n ]->DecRef( );
-    }
+    ClearMatrix();
     delete[] ppP_Matrix;
 
     delete pScToken;
@@ -879,6 +875,7 @@ void TokenPool::Reset()
     maExtNames.clear();
     maExtCellRefs.clear();
     maExtAreaRefs.clear();
+    ClearMatrix();
 }
 
 bool TokenPool::IsSingleOp( const TokenId& rId, const DefTokenId eId ) const
@@ -934,4 +931,16 @@ ScMatrix* TokenPool::GetMatrix( unsigned int n ) const
     return nullptr;
 }
 
+void TokenPool::ClearMatrix()
+{
+    for(sal_uInt16 n = 0 ; n < nP_Matrix ; n++ )
+    {
+        if( ppP_Matrix[ n ] )
+        {
+            ppP_Matrix[ n ]->DecRef( );
+            ppP_Matrix[n] = nullptr;
+        }
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/inc/tokstack.hxx b/sc/source/filter/inc/tokstack.hxx
index 6a1ed79..9ceb2a4 100644
--- a/sc/source/filter/inc/tokstack.hxx
+++ b/sc/source/filter/inc/tokstack.hxx
@@ -182,6 +182,7 @@ private:
         bool                        GrowMatrix();
         bool                        GetElement( const sal_uInt16 nId );
         bool                        GetElementRek( const sal_uInt16 nId );
+        void                        ClearMatrix();
 public:
     TokenPool( svl::SharedStringPool& rSPool );
                                     ~TokenPool();


More information about the Libreoffice-commits mailing list