sc/source/core/tool/interpr4.cxx |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

New commits:
commit 9757290668b50827ab22597a73a4850ebf3f6521
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sat Apr 13 16:35:28 2024 +0100
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Mon May 6 15:09:55 2024 +0200

    Related: tdf#160056 don't set nVal twice
    
    Change-Id: I0da3e0c7f18271f6104d52b50d65e96564650b8b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166054
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit 63b237e1e8147f54e6d4db4671f612a656200e2f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166300
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 95dff9f1cc18..9a483103e3f9 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2099,7 +2099,7 @@ double ScInterpreter::GetDoubleFromMatrix(const 
ScMatrixRef& pMat)
 
 double ScInterpreter::GetDouble()
 {
-    double nVal(0.0);
+    double nVal;
     switch( GetRawStackType() )
     {
         case svDouble:
@@ -2134,13 +2134,16 @@ double ScInterpreter::GetDouble()
         {
             ScExternalRefCache::TokenRef pToken;
             PopExternalSingleRef(pToken);
-            if (nGlobalError == FormulaError::NONE)
+            if (nGlobalError != FormulaError::NONE)
             {
-                if (pToken->GetType() == svDouble || pToken->GetType() == 
svEmptyCell)
-                    nVal = pToken->GetDouble();
-                else
-                    nVal = ConvertStringToValue( 
pToken->GetString().getString());
+                nVal = 0.0;
+                break;
             }
+
+            if (pToken->GetType() == svDouble || pToken->GetType() == 
svEmptyCell)
+                nVal = pToken->GetDouble();
+            else
+                nVal = ConvertStringToValue( pToken->GetString().getString());
         }
         break;
         case svExternalDoubleRef:
@@ -2148,7 +2151,10 @@ double ScInterpreter::GetDouble()
             ScMatrixRef pMat;
             PopExternalDoubleRef(pMat);
             if (nGlobalError != FormulaError::NONE)
+            {
+                nVal = 0.0;
                 break;
+            }
 
             nVal = GetDoubleFromMatrix(pMat);
         }

Reply via email to