changeset 24525:887121a6d7cf v8.2.2802

patch 8.2.2802: Vim9: illegal memory access Commit: https://github.com/vim/vim/commit/a6aa16423fdd0518ec9f3074b0d32b1d651d41e8 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Apr 23 19:32:23 2021 +0200 patch 8.2.2802: Vim9: illegal memory access Problem: Vim9: illegal memory access. Solution: Check for comment before checking for white space. (closes https://github.com/vim/vim/issues/8142)
author Bram Moolenaar <Bram@vim.org>
date Fri, 23 Apr 2021 19:45:04 +0200
parents 154450445788
children df39b96338bb
files src/eval.c src/testdir/test_vim9_func.vim src/version.c
diffstat 3 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -2083,7 +2083,8 @@ getline_peek_skip_comments(evalarg_T *ev
  * If inside Vim9 script, "arg" points to the end of a line (ignoring a #
  * comment) and there is a next line, return the next line (skipping blanks)
  * and set "getnext".
- * Otherwise just return "arg" unmodified and set "getnext" to FALSE.
+ * Otherwise return the next non-white at or after "arg" and set "getnext" to
+ * FALSE.
  * "arg" must point somewhere inside a line, not at the start.
  */
     char_u *
@@ -2095,7 +2096,7 @@ eval_next_non_blank(char_u *arg, evalarg
     if (in_vim9script()
 	    && evalarg != NULL
 	    && (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL)
-	    && (*p == NUL || (VIM_ISWHITE(p[-1]) && vim9_comment_start(p))))
+	    && (*p == NUL || (vim9_comment_start(p) && VIM_ISWHITE(p[-1]))))
     {
 	char_u *next;
 
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -2692,5 +2692,15 @@ def Test_too_many_arguments()
   CheckDefExecAndScriptFailure(lines, 'E1106: One argument too many', 1)
 enddef
 
+def Test_closing_brace_at_start_of_line()
+  var lines =<< trim END
+      def Func()
+      enddef
+      Func(
+      )
+  END
+  call CheckDefAndScriptSuccess(lines)
+enddef
+
 
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2802,
+/**/
     2801,
 /**/
     2800,