diff options
author | Eike Rathke <erack@redhat.com> | 2017-05-12 17:48:53 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-05-12 17:54:36 +0200 |
commit | 534746c99e88270ec766aeb12970a282a0a16520 (patch) | |
tree | 3ceec49c4763a5ffb8b3195a3c35d826cf3dc2d3 /formula | |
parent | c882c60f54cc90740a674eed8c47bde0e9959652 (diff) |
Introduce and check FormulaTokenArray::mbFinalized to not add further tokens
Obviously after FormulaTokenArray::Assign() or the copy-ctor for that matter,
new tokens can not be added anymore to the shrunk code array. We don't do it,
but ensure that it isn't done in future..
Change-Id: Ibc0115f9f38e9745028a7459c61408c188783d03
Diffstat (limited to 'formula')
-rw-r--r-- | formula/source/core/api/token.cxx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index cc5a93573fe5..63afd00cfc36 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -728,7 +728,8 @@ FormulaTokenArray::FormulaTokenArray() : nMode(ScRecalcMode::NORMAL), bHyperLink(false), mbFromRangeName(false), - mbShareable(true) + mbShareable(true), + mbFinalized(false) { } @@ -752,6 +753,7 @@ void FormulaTokenArray::Assign( const FormulaTokenArray& r ) bHyperLink = r.bHyperLink; mbFromRangeName = r.mbFromRangeName; mbShareable = r.mbShareable; + mbFinalized = r.mbFinalized; pCode = nullptr; pRPN = nullptr; FormulaToken** pp; @@ -761,6 +763,7 @@ void FormulaTokenArray::Assign( const FormulaTokenArray& r ) memcpy( pp, r.pCode, nLen * sizeof( FormulaToken* ) ); for( sal_uInt16 i = 0; i < nLen; i++ ) (*pp++)->IncRef(); + mbFinalized = true; } if( nRPN ) { @@ -779,6 +782,7 @@ void FormulaTokenArray::Assign( sal_uInt16 nCode, FormulaToken **pTokens ) nLen = nCode; pCode = new FormulaToken*[ nLen ]; + mbFinalized = true; for( sal_uInt16 i = 0; i < nLen; i++ ) { @@ -814,6 +818,7 @@ void FormulaTokenArray::Clear() bHyperLink = false; mbFromRangeName = false; mbShareable = true; + mbFinalized = false; ClearRecalcMode(); } @@ -923,6 +928,13 @@ sal_uInt16 FormulaTokenArray::RemoveToken( sal_uInt16 nOffset, sal_uInt16 nCount FormulaToken* FormulaTokenArray::Add( FormulaToken* t ) { + assert(!mbFinalized); + if (mbFinalized) + { + t->DeleteIfZeroRef(); + return nullptr; + } + if( !pCode ) pCode = new FormulaToken*[ FORMULA_MAXTOKENS ]; if( nLen < FORMULA_MAXTOKENS - 1 ) |