0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 9.0.0212: invalid memory access when compiling :unlet

Problem:    Invalid memory access when compiling :unlet.
Solution:   Don't read past the end of the line.
This commit is contained in:
Bram Moolenaar
2022-08-14 21:46:07 +01:00
parent d1d8f6bacb
commit dbdd16b625
3 changed files with 17 additions and 2 deletions

View File

@@ -1740,12 +1740,19 @@ def Test_lockvar()
lines =<< trim END lines =<< trim END
def _() def _()
s:0([], s:0)
lockv lockv
enddef enddef
defcomp defcomp
END 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 enddef
def Test_substitute_expr() def Test_substitute_expr()

View File

@@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
212,
/**/ /**/
211, 211,
/**/ /**/

View File

@@ -92,6 +92,12 @@ free_locals(cctx_T *cctx)
int int
check_vim9_unlet(char_u *name) 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) if (name[1] != ':' || vim_strchr((char_u *)"gwtb", *name) == NULL)
{ {
// "unlet s:var" is allowed in legacy script. // "unlet s:var" is allowed in legacy script.