summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-09-03 11:51:41 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-09-03 14:25:43 +0200
commite3545d491e2a2c4ff609a63385994f0c8d388edf (patch)
treea61acf33ec40ef3600196a6c9f0f8be93c8142c8
parent0933bbdd3e297c154a2a01e507ffc6f3f8631d75 (diff)
intermittent forecast.ets.add.fods failure
valgrinding the forecast.ets.add.fods failure gives... a) mnSmplInPrd is 9 b) ScETSForecastCalculation::prefillPerIdx:476 fills mpPerIdx to index 8 with values. c) ScETSForecastCalculation::refill:791 (the bAdditive branch) due to nIdx = ( i > mnSmplInPrd ? i - mnSmplInPrd : i ) with i of 9 gives nIdx of 9 and uninit mpPerIdx[9] is used in the calculation. d) At line 799 (the !bAdditive branch) due to nIdx = ( i >= mnSmplInPrd ? i - mnSmplInPrd : i ) the nIdx used would be 0 not 9 under the same circumstances extending the initialization of prefillPerIdx to zeroing out the next index gives the same results as we usually get and test passes without a need to change it while avoiding the use of an uninitialized value. Change-Id: Ib4629b28ecf2389c0c7611137b756d4d2d9fd700 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101997 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/qa/unit/functions_test.cxx4
-rw-r--r--sc/source/core/tool/interpr8.cxx2
2 files changed, 2 insertions, 4 deletions
diff --git a/sc/qa/unit/functions_test.cxx b/sc/qa/unit/functions_test.cxx
index 1a48c03432d9..16e0a530a5e5 100644
--- a/sc/qa/unit/functions_test.cxx
+++ b/sc/qa/unit/functions_test.cxx
@@ -40,10 +40,6 @@ bool FunctionsTest::load(const OUString& rFilter, const OUString& rURL,
ScDocument& rDoc = xDocShRef->GetDocument();
-#ifdef __APPLE__
-// FIXME tends to fail a lot
-if (!rURL.endsWith("forecast.ets.add.fods"))
-#endif
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, rDoc.GetValue(1, 2, 0), 1e-14);
xDocShRef->DoClose();
diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx
index 1ab5a79aee30..c8645083c2ef 100644
--- a/sc/source/core/tool/interpr8.cxx
+++ b/sc/source/core/tool/interpr8.cxx
@@ -475,6 +475,8 @@ bool ScETSForecastCalculation::prefillPerIdx()
}
mpPerIdx[ j ] = fI / nPeriods;
}
+ if (mnSmplInPrd < mnCount)
+ mpPerIdx[mnSmplInPrd] = 0.0;
}
return true;
}