Patch 8.2.1796
Problem:    Vim9: invalid memory access with weird function name. (Dhiraj
            Mishra)
Solution:   Check the name is valid.  Add a test.
Files:      src/userfunc.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.1795/src/userfunc.c      2020-09-27 15:19:23.642118924 +0200
--- src/userfunc.c      2020-10-04 13:36:48.741129200 +0200
***************
*** 2374,2379 ****
--- 2374,2380 ----
      int               extra = 0;
      lval_T    lv;
      int               vim9script;
+     static char *e_function_name = N_("E129: Function name required");
  
      if (fdp != NULL)
        CLEAR_POINTER(fdp);
***************
*** 2401,2407 ****
      if (end == start)
      {
        if (!skip)
!           emsg(_("E129: Function name required"));
        goto theend;
      }
      if (end == NULL || (lv.ll_tv != NULL && (lead > 2 || lv.ll_range)))
--- 2402,2408 ----
      if (end == start)
      {
        if (!skip)
!           emsg(_(e_function_name));
        goto theend;
      }
      if (end == NULL || (lv.ll_tv != NULL && (lead > 2 || lv.ll_range)))
***************
*** 2517,2522 ****
--- 2518,2529 ----
        }
        len = (int)(end - lv.ll_name);
      }
+     if (len <= 0)
+     {
+       if (!skip)
+           emsg(_(e_function_name));
+       goto theend;
+     }
  
      // In Vim9 script a user function is script-local by default.
      vim9script = ASCII_ISUPPER(*start) && in_vim9script();
*** ../vim-8.2.1795/src/testdir/test_vim9_func.vim      2020-10-01 
21:37:17.798009505 +0200
--- src/testdir/test_vim9_func.vim      2020-10-04 13:39:32.408333755 +0200
***************
*** 1906,1911 ****
--- 1906,1937 ----
    delete('XclosureDir', 'rf')
  enddef
  
+ def Test_invalid_function_name()
+   var lines =<< trim END
+       vim9script
+       def s: list<string>
+   END
+   CheckScriptFailure(lines, 'E129:')
+ 
+   lines =<< trim END
+       vim9script
+       def g: list<string>
+   END
+   CheckScriptFailure(lines, 'E129:')
+ 
+   lines =<< trim END
+       vim9script
+       def <SID>: list<string>
+   END
+   CheckScriptFailure(lines, 'E884:')
+ 
+   lines =<< trim END
+       vim9script
+       def F list<string>
+   END
+   CheckScriptFailure(lines, 'E488:')
+ enddef
+ 
  def Test_partial_call()
    var Xsetlist = function('setloclist', [0])
    Xsetlist([], ' ', {'title': 'test'})
*** ../vim-8.2.1795/src/version.c       2020-10-03 22:51:42.894813399 +0200
--- src/version.c       2020-10-04 13:42:07.855660263 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1796,
  /**/

-- 
This planet has -- or rather had -- a problem, which was this: most
of the people living on it were unhappy for pretty much of the time.
Many solutions were suggested for this problem, but most of these
were largely concerned with the movements of small green pieces of
paper, which is odd because on the whole it wasn't the small green
pieces of paper that were unhappy.
                -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202010041144.094BiLQX2092876%40masaka.moolenaar.net.

Raspunde prin e-mail lui