Skip to content

Commit

Permalink
patch 9.0.0211: invalid memory access when compiling :lockvar
Browse files Browse the repository at this point in the history
Problem:    Invalid memory access when compiling :lockvar.
Solution:   Don't read past the end of the line.
  • Loading branch information
brammool committed Aug 14, 2022
1 parent c3a483f commit d1d8f6b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/testdir/test_vim9_cmd.vim
Expand Up @@ -1737,6 +1737,15 @@ def Test_lockvar()
UnLockIt()
END
v9.CheckScriptFailure(lines, 'E46', 1)

lines =<< trim END
def _()
s:0([], s:0)
lockv
enddef
defcomp
END
v9.CheckScriptFailure(lines, 'E179', 2)
enddef

def Test_substitute_expr()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -735,6 +735,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
211,
/**/
210,
/**/
Expand Down
9 changes: 7 additions & 2 deletions src/vim9cmds.c
Expand Up @@ -188,10 +188,17 @@ compile_lock_unlock(
size_t len;
char_u *buf;
isntype_T isn = ISN_EXEC;
char *cmd = eap->cmdidx == CMD_lockvar ? "lockvar" : "unlockvar";

if (cctx->ctx_skip == SKIP_YES)
return OK;

if (*p == NUL)
{
semsg(_(e_argument_required_for_str), cmd);
return FAIL;
}

// Cannot use :lockvar and :unlockvar on local variables.
if (p[1] != ':')
{
Expand Down Expand Up @@ -223,8 +230,6 @@ compile_lock_unlock(
ret = FAIL;
else
{
char *cmd = eap->cmdidx == CMD_lockvar ? "lockvar" : "unlockvar";

if (deep < 0)
vim_snprintf((char *)buf, len, "%s! %s", cmd, p);
else
Expand Down

0 comments on commit d1d8f6b

Please sign in to comment.