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

New commits:
commit 6b6b83b43fcae13e30a9ca67b421187a5e0d7142
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Sat Apr 29 18:59:30 2023 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Sat Apr 29 20:03:00 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

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index bc7711f08f06..9e2277f60392 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7078,7 +7078,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();
@@ -7212,6 +7213,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