Kaydet (Commit) 209cc5c2 authored tarafından Eike Rathke's avatar Eike Rathke

Set error on more than max params (255) per function

Parameter count is size byte, so.. SUM(1,1,1,...) with 256 arguments resulted
in 0 (uint8 wrapping around).

Change-Id: Ib9997ad0d0d13d4c5171f276148b6c5cad570d5b
üst 4a77a818
......@@ -1490,7 +1490,7 @@ void FormulaCompiler::Factor()
}
else
SetError( FormulaError::PairExpected);
sal_uInt8 nSepCount = 0;
sal_uInt32 nSepCount = 0;
const sal_uInt16 nSepPos = maArrIterator.GetIndex() - 1; // separator position, if any
if( !bNoParam )
{
......@@ -1500,6 +1500,8 @@ void FormulaCompiler::Factor()
NextToken();
CheckSetForceArrayParameter( mpToken, nSepCount);
nSepCount++;
if (nSepCount > FORMULA_MAXPARAMS)
SetError( FormulaError::CodeOverflow);
eOp = Expression();
}
}
......@@ -1597,7 +1599,7 @@ void FormulaCompiler::Factor()
}
else
SetError( FormulaError::PairExpected);
sal_uInt8 nSepCount = 0;
sal_uInt32 nSepCount = 0;
if( !bNoParam )
{
nSepCount++;
......@@ -1606,6 +1608,8 @@ void FormulaCompiler::Factor()
NextToken();
CheckSetForceArrayParameter( mpToken, nSepCount);
nSepCount++;
if (nSepCount > FORMULA_MAXPARAMS)
SetError( FormulaError::CodeOverflow);
eOp = Expression();
}
}
......
......@@ -40,6 +40,7 @@
#define FORMULA_MAXJUMPCOUNT 32 /* maximum number of jumps (ocChoose) */
#define FORMULA_MAXTOKENS 8192 /* maximum number of tokens in formula */
#define FORMULA_MAXPARAMS 255 /* maximum number of parameters per function (byte) */
namespace com { namespace sun { namespace star {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment