sc/source/core/tool/interpr1.cxx |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 700e918ba7c481034a4629fbbf95e829e2a2786a
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Sat Apr 29 18:59:30 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue May 2 11:09:40 2023 +0200

    Resolves: tdf#119659 Check found position for result vector
    
    Change-Id: Idc454462c47b6c7b7b7cb6c86b08650d059221c7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151186
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 89e725dc3236f6f8ad226adf6508f7fc753b5572)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151190
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index ac0fb22b6231..b833e3f48f24 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7072,7 +7072,8 @@ void ScInterpreter::ScLookup()
         if (pResMat)
         {
             VectorMatrixAccessor aResMatAcc(*pResMat, bVertical);
-            // result array is matrix.
+            // Result array is matrix.
+            // Note this does not replicate the other dimension.
             if (o3tl::make_unsigned(nDelta) >= aResMatAcc.GetElementCount())
             {
                 PushNA();
@@ -7206,6 +7207,12 @@ void ScInterpreter::ScLookup()
     {
         VectorMatrixAccessor aResMatAcc(*pResMat, bVertical);
         // Use the matrix result array.
+        // Note this does not replicate the other dimension.
+        if (o3tl::make_unsigned(nDelta) >= aResMatAcc.GetElementCount())
+        {
+            PushNA();
+            return;
+        }
         if (aResMatAcc.IsValue(nDelta))
             PushDouble(aResMatAcc.GetDouble(nDelta));
         else

Reply via email to