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

patch 9.0.0742: reading past end of the line when compiling a function

Problem:    Reading past end of the line when compiling a function with
            errors.
Solution:   Do not return an invalid pointer.  Fix skipping redirection.
This commit is contained in:
Bram Moolenaar
2022-10-13 16:12:57 +01:00
parent d93009eb35
commit 3558afe9e9
5 changed files with 136 additions and 33 deletions

View File

@@ -1283,6 +1283,19 @@ vim9_declare_error(char_u *name)
semsg(_(e_cannot_declare_a_scope_variable), scope, name);
}
/*
* Return TRUE if "name" is a valid register to use.
* Return FALSE and give an error message if not.
*/
static int
valid_dest_reg(int name)
{
if ((name == '@' || valid_yank_reg(name, FALSE)) && name != '.')
return TRUE;
emsg_invreg(name);
return FAIL;
}
/*
* For one assignment figure out the type of destination. Return it in "dest".
* When not recognized "dest" is not set.
@@ -1364,12 +1377,8 @@ get_var_dest(
}
else if (*name == '@')
{
if (name[1] != '@'
&& (!valid_yank_reg(name[1], FALSE) || name[1] == '.'))
{
emsg_invreg(name[1]);
if (!valid_dest_reg(name[1]))
return FAIL;
}
*dest = dest_reg;
*type = name[1] == '#' ? &t_number_or_string : &t_string;
}
@@ -1445,7 +1454,11 @@ compile_lhs(
// "var_end" is the end of the variable/option/etc. name.
lhs->lhs_dest_end = skip_var_one(var_start, FALSE);
if (*var_start == '@')
{
if (!valid_dest_reg(var_start[1]))
return FAIL;
var_end = var_start + 2;
}
else
{
// skip over the leading "&", "&l:", "&g:" and "$"