sc/source/core/data/column4.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
New commits: commit fb9270b238cba4f36e595c5d7f4d85f6f3f18e1c Author: Kohei Yoshida <ko...@libreoffice.org> AuthorDate: Wed Mar 2 18:35:58 2022 -0500 Commit: Kohei Yoshida <ko...@libreoffice.org> CommitDate: Thu Mar 3 01:17:16 2022 +0100 Check for cached formula block count to make sure it's correct. Change-Id: I16237d26bb9e55ba5c3e65087be98ba8f8086d56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130899 Tested-by: Jenkins Reviewed-by: Kohei Yoshida <ko...@libreoffice.org> diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 22bd15cb271c..e9b7d1d189dc 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -2150,7 +2150,17 @@ void ScColumn::CheckIntegrity() const throw std::runtime_error(os.str()); } - // Add more integrity checks as needed. + size_t nCount = std::count_if(maCells.cbegin(), maCells.cend(), + [](const auto& blk) { return blk.type == sc::element_type_formula; } + ); + + if (mnBlkCountFormula != nCount) + { + std::ostringstream os; + os << "incorrect cached formula block count (expected=" << nCount << "; actual=" + << mnBlkCountFormula << ")"; + throw std::runtime_error(os.str()); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */