sc/source/core/tool/interpr4.cxx |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

New commits:
commit ac4560a37dacfa4fee60e36d1b3de7790b81dc20
Author: Eike Rathke <er...@redhat.com>
Date:   Wed Mar 9 16:18:55 2016 +0100

    Resolves: tdf#95226 second case, stack error count in JumpMatrix context
    
    For the early bail out on errors to work correctly and not prematurely
    end calculations the current error function needs to be stacked in
    JumpMatrix context, otherwise we may end up with
    ((nErrorFunction=74)>=(nErrorFunctionCount=2)) or some such..
    
    Change-Id: I3559e15180694961585db92f6aa98a46430ae372
    (cherry picked from commit 62b40429946c0e5021912072dc79a60fc11fce06)
    Reviewed-on: https://gerrit.libreoffice.org/23089
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index cc0b4bc..011d9c9 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -74,6 +74,7 @@
 #include <basic/basmgr.hxx>
 #include <vbahelper/vbaaccesshelper.hxx>
 #include <memory>
+#include <stack>
 
 using namespace com::sun::star;
 using namespace formula;
@@ -3557,6 +3558,7 @@ StackVar ScInterpreter::Interpret()
     sal_uLong nRetIndexExpr = 0;
     sal_uInt16 nErrorFunction = 0;
     sal_uInt16 nErrorFunctionCount = 0;
+    std::stack<sal_uInt16> aErrorFunctionStack;
     sal_uInt16 nStackBase;
 
     nGlobalError = 0;
@@ -4089,7 +4091,19 @@ StackVar ScInterpreter::Interpret()
             else
                 nLevel = 0;
             if ( nLevel == 1 || (nLevel == 2 && aCode.IsEndOfPath()) )
+            {
+                if (nLevel == 1)
+                    aErrorFunctionStack.push( nErrorFunction);
                 bGotResult = JumpMatrix( nLevel );
+                if (aErrorFunctionStack.empty())
+                    assert(!"ScInterpreter::Interpret - aErrorFunctionStack 
empty in JumpMatrix context");
+                else
+                {
+                    nErrorFunction = aErrorFunctionStack.top();
+                    if (bGotResult)
+                        aErrorFunctionStack.pop();
+                }
+            }
             else
                 pJumpMatrix = nullptr;
         } while ( bGotResult );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to