summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-13 19:15:16 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-13 20:21:02 +0000
commit3887e8439a6928d2f608315f7050d012be65d208 (patch)
tree53b82a845df3f49b48acf59c6bac3b0f1a38bb77
parent98d48dad9e807a4a40f4c3d1b5280d9e5156cb18 (diff)
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@kohei.us> Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/source/filter/excel/tokstack.cxx19
-rw-r--r--sc/source/filter/inc/tokstack.hxx1
2 files changed, 15 insertions, 5 deletions
diff --git a/sc/source/filter/excel/tokstack.cxx b/sc/source/filter/excel/tokstack.cxx
index 1bafcfbc1d09..31e89959406c 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 6a1ed79715b5..9ceb2a4e9aa3 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();