summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2016-02-29 22:18:23 +0100
committerMarco Cecchetti <marco.cecchetti@collabora.com>2016-03-01 11:14:22 +0100
commit9b7f72203f2b9f6b95d927c695f7f48b86b251ee (patch)
tree0c6b5fb3034c17692c3ed69522193c846734847b
parent1d46afc6a7097f3265654f21ad2e01d1a8d757c0 (diff)
tdf#97369/#97587 - Further fix SUMming in the software interpreter
When SUMming in the software interpreter involved trailing empty cells, code tried to read beyond numeric array limit. Change-Id: I50c1148e7e79d02bedb02a771df172035112915c
-rw-r--r--sc/source/core/inc/arraysumfunctor.hxx7
-rw-r--r--sc/source/core/tool/scmatrix.cxx2
2 files changed, 6 insertions, 3 deletions
diff --git a/sc/source/core/inc/arraysumfunctor.hxx b/sc/source/core/inc/arraysumfunctor.hxx
index 3955fd9451f6..d94bf74240a3 100644
--- a/sc/source/core/inc/arraysumfunctor.hxx
+++ b/sc/source/core/inc/arraysumfunctor.hxx
@@ -51,12 +51,15 @@ public:
if (hasSSE2)
{
- while (!isAligned<double, 16>(pCurrent))
+ while ( i < mnSize && !isAligned<double, 16>(pCurrent))
{
fSum += *pCurrent++;
i++;
}
- fSum += executeSSE2(i, pCurrent);
+ if( i < mnSize )
+ {
+ fSum += executeSSE2(i, pCurrent);
+ }
}
else
fSum += executeUnrolled(i, pCurrent);
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 6018ca1bcc2f..e2dde4e53bf3 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -3401,7 +3401,7 @@ ScMatrix::IterateResult ScVectorRefMatrix::Sum(bool bTextAsZero) const
{
return ScMatrix::IterateResult(0.0, 0.0, 0);
}
- else if (nDataSize > mpToken->GetArrayLength() + mnRowStart)
+ else if (nDataSize > mpToken->GetArrayLength() - mnRowStart)
{
nDataSize = mpToken->GetArrayLength() - mnRowStart;
}