]> granicus.if.org Git - vim/commitdiff
patch 9.0.0212: invalid memory access when compiling :unlet v9.0.0212
authorBram Moolenaar <Bram@vim.org>
Sun, 14 Aug 2022 20:46:07 +0000 (21:46 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 14 Aug 2022 20:46:07 +0000 (21:46 +0100)
Problem:    Invalid memory access when compiling :unlet.
Solution:   Don't read past the end of the line.

src/testdir/test_vim9_cmd.vim
src/version.c
src/vim9cmds.c

index 79f19f0389a0d777019945512cb92d52ca325e1e..5484ecb7757e586fffe924ddf48817c600aae865 100644 (file)
@@ -1740,12 +1740,19 @@ def Test_lockvar()
 
   lines =<< trim END
       def _()
-        s:0([], s:0)
         lockv
       enddef
       defcomp
   END
-  v9.CheckScriptFailure(lines, 'E179', 2)
+  v9.CheckScriptFailure(lines, 'E179', 1)
+
+  lines =<< trim END
+      def T()
+        unlet
+      enddef
+      defcomp
+  END
+  v9.CheckScriptFailure(lines, 'E179', 1)
 enddef
 
 def Test_substitute_expr()
index 3f0bf5151ad21bc5344c60a0d2c7b31f84ea54b3..7de71581568e7c3da0212299347d0f07930b6b7b 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    212,
 /**/
     211,
 /**/
index 35a382138bf3be8fc9e4a86fc36c6598e1d845ae..93032d6bf154e303a72c0589b7ae1d8dcc7a44a7 100644 (file)
@@ -92,6 +92,12 @@ free_locals(cctx_T *cctx)
     int
 check_vim9_unlet(char_u *name)
 {
+    if (*name == NUL)
+    {
+       semsg(_(e_argument_required_for_str), "unlet");
+       return FAIL;
+    }
+
     if (name[1] != ':' || vim_strchr((char_u *)"gwtb", *name) == NULL)
     {
        // "unlet s:var" is allowed in legacy script.