]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas. v8.2.3175
authorBram Moolenaar <Bram@vim.org>
Sun, 18 Jul 2021 11:42:29 +0000 (13:42 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 18 Jul 2021 11:42:29 +0000 (13:42 +0200)
Problem:    Vim9: using illegal pointer with inline function inside a lambda.
Solution:   Clear eval_tofree_cmdline when advancing to the next line.
            (closes #8578)

src/eval.c
src/testdir/test_vim9_func.vim
src/version.c

index 5dc1642a169aeaf64a97704e881f9471e71e1270..2e8ab3d8fc29e0b9a17909a3f23c7f9da86e37b0 100644 (file)
@@ -2177,6 +2177,11 @@ eval_next_line(evalarg_T *evalarg)
        vim_free(evalarg->eval_tofree);
        evalarg->eval_tofree = line;
     }
+
+    // Advanced to the next line, "arg" no longer points into the previous
+    // line.
+    VIM_CLEAR(evalarg->eval_tofree_cmdline);
+
     return skipwhite(line);
 }
 
index c89c13e2dc8aa7dd9b7df84c9de42c4491730e79..a2c4e7daed3534d070e8aaca1820e4df0d3ba124 100644 (file)
@@ -2265,6 +2265,22 @@ def Test_nested_inline_lambda()
         })
   END
   CheckScriptSuccess(lines)
+
+  lines =<< trim END
+      vim9script
+
+      def s:func()
+        range(10)
+          ->mapnew((_, _) => ({
+            key: range(10)->mapnew((_, _) => {
+              return ' '
+            }),
+          }))
+      enddef
+
+      defcomp
+  END
+  CheckScriptSuccess(lines)
 enddef
 
 def Shadowed(): list<number>
index e1421ddb4eccb6723e1f07cbfacf4fd05cc4ea24..8b674d377383911d07ba922b352d4bba2ce44641 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3175,
 /**/
     3174,
 /**/