summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-04-23 20:23:23 +0200
committerEike Rathke <erack@redhat.com>2016-04-23 20:24:46 +0200
commitb0992e11905e36a64edeb92a13acfde5837c1878 (patch)
treebba9da052c02d097f0c8781e2e4877ef2ee58246
parent9a0735bcf984b2f23d60ee377324ddc10a49d048 (diff)
fully check for adjacent RPN end, tdf#96426 follow-up
Change-Id: I886e559c6f6041bf4889fdd6d89c12a10be70e5f
-rw-r--r--formula/source/core/api/FormulaCompiler.cxx18
1 files changed, 13 insertions, 5 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 303e00e7a19c..535dc4187201 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1634,6 +1634,16 @@ bool isIntersectable( FormulaToken** pCode1, FormulaToken** pCode2 )
return false;
}
+bool isAdjacentRpnEnd( sal_uInt16 nPC,
+ FormulaToken const * const * const pCode,
+ FormulaToken const * const * const pCode1,
+ FormulaToken const * const * const pCode2 )
+{
+ return nPC >= 2 && pCode1 && pCode2 &&
+ (pCode2 - pCode1 == 1) && (pCode - pCode2 == 1) &&
+ (*pCode1 != nullptr) && (*pCode2 != nullptr);
+}
+
}
void FormulaCompiler::IntersectionLine()
@@ -1653,7 +1663,7 @@ void FormulaCompiler::IntersectionLine()
// functions (potentially returning references, if not then a space
// or no space would be a syntax error anyway), not other operators
// or operands. Else discard.
- if (isIntersectable( pCode1, pCode2))
+ if (isAdjacentRpnEnd( pc, pCode, pCode1, pCode2) && isIntersectable( pCode1, pCode2))
{
FormulaTokenRef pIntersect( new FormulaByteToken( ocIntersect));
// Replace ocSpaces with ocIntersect so that when switching
@@ -1812,12 +1822,10 @@ FormulaTokenRef FormulaCompiler::ExtendRangeReference( FormulaToken & /*rTok1*/,
bool FormulaCompiler::MergeRangeReference( FormulaToken * * const pCode1, FormulaToken * const * const pCode2 )
{
- FormulaToken *p1, *p2;
- if (pc < 2 || !pCode1 || !pCode2 ||
- (pCode2 - pCode1 != 1) || (pCode - pCode2 != 1) ||
- ((p1 = *pCode1) == nullptr) || ((p2 = *pCode2) == nullptr) )
+ if (!isAdjacentRpnEnd( pc, pCode, pCode1, pCode2))
return false;
+ FormulaToken *p1 = *pCode1, *p2 = *pCode2;
FormulaTokenRef p = ExtendRangeReference( *p1, *p2);
if (!p)
return false;