mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.2377: Vim9: crash when using a range after another expression
Problem: Vim9: crash when using a range after another expression. Solution: Set the variable type to number. Fix using :put with a range and the "=" register. (closes #7706)
This commit is contained in:
@@ -750,6 +750,10 @@ def Test_put_command()
|
|||||||
:+2put! a
|
:+2put! a
|
||||||
assert_equal('aaa', getline(4))
|
assert_equal('aaa', getline(4))
|
||||||
|
|
||||||
|
[]->mapnew(() => 0)
|
||||||
|
:$put ='end'
|
||||||
|
assert_equal('end', getline('$'))
|
||||||
|
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
CheckDefFailure(['put =xxx'], 'E1001:')
|
CheckDefFailure(['put =xxx'], 'E1001:')
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
2377,
|
||||||
/**/
|
/**/
|
||||||
2376,
|
2376,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -3326,10 +3326,6 @@ call_def_function(
|
|||||||
exarg_T ea;
|
exarg_T ea;
|
||||||
char *errormsg;
|
char *errormsg;
|
||||||
|
|
||||||
if (GA_GROW(&ectx.ec_stack, 1) == FAIL)
|
|
||||||
goto failed;
|
|
||||||
++ectx.ec_stack.ga_len;
|
|
||||||
tv = STACK_TV_BOT(-1);
|
|
||||||
ea.line2 = 0;
|
ea.line2 = 0;
|
||||||
ea.addr_count = 0;
|
ea.addr_count = 0;
|
||||||
ea.addr_type = ADDR_LINES;
|
ea.addr_type = ADDR_LINES;
|
||||||
@@ -3337,6 +3333,13 @@ call_def_function(
|
|||||||
ea.skip = FALSE;
|
ea.skip = FALSE;
|
||||||
if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
|
if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
|
if (GA_GROW(&ectx.ec_stack, 1) == FAIL)
|
||||||
|
goto failed;
|
||||||
|
++ectx.ec_stack.ga_len;
|
||||||
|
tv = STACK_TV_BOT(-1);
|
||||||
|
tv->v_type = VAR_NUMBER;
|
||||||
|
tv->v_lock = 0;
|
||||||
if (ea.addr_count == 0)
|
if (ea.addr_count == 0)
|
||||||
tv->vval.v_number = curwin->w_cursor.lnum;
|
tv->vval.v_number = curwin->w_cursor.lnum;
|
||||||
else
|
else
|
||||||
@@ -3351,18 +3354,6 @@ call_def_function(
|
|||||||
char_u *expr = NULL;
|
char_u *expr = NULL;
|
||||||
int dir = FORWARD;
|
int dir = FORWARD;
|
||||||
|
|
||||||
if (regname == '=')
|
|
||||||
{
|
|
||||||
tv = STACK_TV_BOT(-1);
|
|
||||||
if (tv->v_type == VAR_STRING)
|
|
||||||
expr = tv->vval.v_string;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
expr = typval2string(tv, TRUE); // allocates value
|
|
||||||
clear_tv(tv);
|
|
||||||
}
|
|
||||||
--ectx.ec_stack.ga_len;
|
|
||||||
}
|
|
||||||
if (lnum < -2)
|
if (lnum < -2)
|
||||||
{
|
{
|
||||||
// line number was put on the stack by ISN_RANGE
|
// line number was put on the stack by ISN_RANGE
|
||||||
@@ -3377,6 +3368,19 @@ call_def_function(
|
|||||||
dir = BACKWARD;
|
dir = BACKWARD;
|
||||||
else if (lnum >= 0)
|
else if (lnum >= 0)
|
||||||
curwin->w_cursor.lnum = iptr->isn_arg.put.put_lnum;
|
curwin->w_cursor.lnum = iptr->isn_arg.put.put_lnum;
|
||||||
|
|
||||||
|
if (regname == '=')
|
||||||
|
{
|
||||||
|
tv = STACK_TV_BOT(-1);
|
||||||
|
if (tv->v_type == VAR_STRING)
|
||||||
|
expr = tv->vval.v_string;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
expr = typval2string(tv, TRUE); // allocates value
|
||||||
|
clear_tv(tv);
|
||||||
|
}
|
||||||
|
--ectx.ec_stack.ga_len;
|
||||||
|
}
|
||||||
check_cursor();
|
check_cursor();
|
||||||
do_put(regname, expr, dir, 1L, PUT_LINE|PUT_CURSLINE);
|
do_put(regname, expr, dir, 1L, PUT_LINE|PUT_CURSLINE);
|
||||||
vim_free(expr);
|
vim_free(expr);
|
||||||
|
Reference in New Issue
Block a user