sc/source/core/tool/compiler.cxx | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
New commits: commit bdbc89b6da2ef4797e496aa0db84069b838b2e73 Author: Balazs Varga <balazs.varga.ext...@allotropia.de> AuthorDate: Sun Oct 13 00:55:18 2024 +0200 Commit: Balazs Varga <balazs.varga.ext...@allotropia.de> CommitDate: Sun Oct 13 20:04:28 2024 +0200 tdf#163375 sc: fix sumproduct crash bacause of non exists token pair at formula editing. Check if both formula token truly exists. Regression commit: ba0ec4a5d2b025b675410cd18890d1cca3bc5a2f (tdf#159687 sc formula SUMPRODUCT performance fix: add more binary) Change-Id: I72d054313f1e9db74aa004dcd8b2012be95c18dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174862 Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de> Tested-by: Jenkins diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 3d30f10fb0ed..50e50d469439 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -6691,12 +6691,15 @@ void ScCompiler::AnnotateTrimOnDoubleRefs() break; FormulaToken* pLHS = *(ppTok - 1); FormulaToken* pRHS = *(ppTok - 2); - StackVar lhsType = pLHS->GetType(); - StackVar rhsType = pRHS->GetType(); - if (lhsType == svDoubleRef && rhsType == svDoubleRef) + if (pLHS && pRHS) { - pLHS->GetDoubleRef()->SetTrimToData(true); - pRHS->GetDoubleRef()->SetTrimToData(true); + StackVar lhsType = pLHS->GetType(); + StackVar rhsType = pRHS->GetType(); + if (lhsType == svDoubleRef && rhsType == svDoubleRef) + { + pLHS->GetDoubleRef()->SetTrimToData(true); + pRHS->GetDoubleRef()->SetTrimToData(true); + } } } break; @@ -6714,8 +6717,6 @@ void ScCompiler::AnnotateTrimOnDoubleRefs() case ocOr: case ocXor: case ocIntersect: - case ocUnion: - case ocRange: { // tdf#160616: Double refs with these operators only // trimmable in case of one parameter @@ -6723,15 +6724,18 @@ void ScCompiler::AnnotateTrimOnDoubleRefs() break; FormulaToken* pLHS = *(ppTok - 1); FormulaToken* pRHS = *(ppTok - 2); - StackVar lhsType = pLHS->GetType(); - StackVar rhsType = pRHS->GetType(); - if (lhsType == svDoubleRef && (rhsType == svSingleRef || rhsType == svDoubleRef)) + if (pLHS && pRHS) { - pLHS->GetDoubleRef()->SetTrimToData(true); - } - if (rhsType == svDoubleRef && (lhsType == svSingleRef || lhsType == svDoubleRef)) - { - pRHS->GetDoubleRef()->SetTrimToData(true); + StackVar lhsType = pLHS->GetType(); + StackVar rhsType = pRHS->GetType(); + if (lhsType == svDoubleRef && (rhsType == svSingleRef || rhsType == svDoubleRef)) + { + pLHS->GetDoubleRef()->SetTrimToData(true); + } + if (rhsType == svDoubleRef && (lhsType == svSingleRef || lhsType == svDoubleRef)) + { + pRHS->GetDoubleRef()->SetTrimToData(true); + } } } break;