summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-06-09 10:45:10 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2020-06-10 22:11:26 +0200
commitc6ee4036e40556dd79f99bf890786b3666cf9ee7 (patch)
treeba2fe324256afa1fb8240dd93058de99192f2741 /sc
parenta7eef5557060504e6e185e8cd8d9acaf6431cd16 (diff)
detect inconsistent SUMIFS() ranges when range reducing (tdf#132431)
03b352b9599514e4e244e1907510713cf1331284 introduced reducing of the SUMIFS range to the cells that actually contain data, but tdf#132431 introduces incorrect ranges that lead to negative indexes, and correctness checking of ranges comes only after the use of these indexes. Change-Id: Ia13db83d222310d470a0a8ecef51dbdd7992d479 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95898 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com> (cherry picked from commit 707cd62e00a75f5a07ef3a4acf5df9d49e8e07c1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96030 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/tool/interpr1.cxx10
1 files changed, 9 insertions, 1 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 56309d6878d7..d4f134fa0b19 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5833,6 +5833,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf
SCROW nStartRowDiff = 0;
SCROW nEndRowDiff = 0;
bool bRangeReduce = false;
+ ScRange aMainRange;
// Range-reduce optimization
if (nParamCount % 2) // Not COUNTIFS
@@ -5856,7 +5857,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf
const ScComplexRefData* pRefData = pMainRangeToken->GetDoubleRef();
if (!pRefData->IsDeleted())
{
- ScRange aMainRange, aSubRange;
+ ScRange aSubRange;
DoubleRefToRange( *pRefData, aMainRange);
if (aMainRange.aStart.Tab() == aMainRange.aEnd.Tab())
@@ -6060,6 +6061,13 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf
if (bRangeReduce)
{
+ // All reference ranges must be of the same size as the main range.
+ if( aMainRange.aEnd.Col() - aMainRange.aStart.Col() != nCol2 - nCol1
+ || aMainRange.aEnd.Row() - aMainRange.aStart.Row() != nRow2 - nRow1)
+ {
+ PushError ( FormulaError::IllegalArgument);
+ return;
+ }
nCol1 += nStartColDiff;
nRow1 += nStartRowDiff;