sc/source/core/tool/compiler.cxx |   34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

New commits:
commit 58e37b0f091be32e65c10171d463a86df62255b7
Author:     Balazs Varga <balazs.varga.ext...@allotropia.de>
AuthorDate: Sun Oct 13 00:55:18 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Oct 14 11:34:20 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
    (cherry picked from commit bdbc89b6da2ef4797e496aa0db84069b838b2e73)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174785
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 652bc14d17fe..7169d269486d 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;

Reply via email to