]> granicus.if.org Git - vim/commitdiff
patch 8.2.2802: Vim9: illegal memory access v8.2.2802
authorBram Moolenaar <Bram@vim.org>
Fri, 23 Apr 2021 17:32:23 +0000 (19:32 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 23 Apr 2021 17:32:23 +0000 (19:32 +0200)
Problem:    Vim9: illegal memory access.
Solution:   Check for comment before checking for white space. (closes #8142)

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

index a9f5ae65be2348132dba7bfe26603ea316a307ca..fbf4f57a522903876856121a8c5893da8d9ec61b 100644 (file)
@@ -2083,7 +2083,8 @@ getline_peek_skip_comments(evalarg_T *evalarg)
  * 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_T *evalarg, int *getnext)
     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;
 
index a941a6102232629f6b051e7cd604f4123fe592ea..8cfb16099dac9f5679b1b6c4ac10fd214837b75e 100644 (file)
@@ -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
index a345fc8c367258a1774504ab6e5e4a90f61f6cd0..0918d5c084db4e086d5b6d51aa85a5c8a8ef3647 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2802,
 /**/
     2801,
 /**/