Patch 8.2.2377
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)
Files: src/vim9execute.c, src/testdir/test_vim9_cmd.vim
*** ../vim-8.2.2376/src/vim9execute.c 2021-01-17 19:20:28.136651661 +0100
--- src/vim9execute.c 2021-01-19 22:45:26.884388113 +0100
***************
*** 3326,3335 ****
exarg_T ea;
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.addr_count = 0;
ea.addr_type = ADDR_LINES;
--- 3326,3331 ----
***************
*** 3337,3342 ****
--- 3333,3345 ----
ea.skip = FALSE;
if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
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)
tv->vval.v_number = curwin->w_cursor.lnum;
else
***************
*** 3351,3368 ****
char_u *expr = NULL;
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)
{
// line number was put on the stack by ISN_RANGE
--- 3354,3359 ----
***************
*** 3377,3382 ****
--- 3368,3386 ----
dir = BACKWARD;
else if (lnum >= 0)
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();
do_put(regname, expr, dir, 1L, PUT_LINE|PUT_CURSLINE);
vim_free(expr);
*** ../vim-8.2.2376/src/testdir/test_vim9_cmd.vim 2021-01-15
18:04:40.102419940 +0100
--- src/testdir/test_vim9_cmd.vim 2021-01-19 22:37:13.541611665 +0100
***************
*** 750,755 ****
--- 750,759 ----
:+2put! a
assert_equal('aaa', getline(4))
+ []->mapnew(() => 0)
+ :$put ='end'
+ assert_equal('end', getline('$'))
+
bwipe!
CheckDefFailure(['put =xxx'], 'E1001:')
*** ../vim-8.2.2376/src/version.c 2021-01-19 22:16:37.680519786 +0100
--- src/version.c 2021-01-19 22:46:22.032250548 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2377,
/**/
--
hundred-and-one symptoms of being an internet addict:
188. You purchase a laptop so you can surf while sitting on the can.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202101192148.10JLmXDf1377158%40masaka.moolenaar.net.