Patch 8.2.2887

4 views
Skip to first unread message

Bram Moolenaar

unread,
May 26, 2021, 1:49:46 PM5/26/21
to vim...@googlegroups.com

Patch 8.2.2887
Problem: Crash when passing null string to fullcommand().
Solution: Check for NULL pointer. (closes #8256)
Files: src/ex_docmd.c, src/testdir/test_cmdline.vim


*** ../vim-8.2.2886/src/ex_docmd.c 2021-05-18 21:46:27.712961269 +0200
--- src/ex_docmd.c 2021-05-26 19:48:53.792273759 +0200
***************
*** 3791,3802 ****
char_u *name = argvars[0].vval.v_string;
char_u *p;

! while (name[0] != NUL && name[0] == ':')
name++;
name = skip_range(name, TRUE, NULL);

- rettv->v_type = VAR_STRING;
-
ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
ea.cmdidx = (cmdidx_T)0;
p = find_ex_command(&ea, NULL, NULL, NULL);
--- 3791,3805 ----
char_u *name = argvars[0].vval.v_string;
char_u *p;

! rettv->v_type = VAR_STRING;
! rettv->vval.v_string = NULL;
! if (name == NULL)
! return;
!
! while (*name != NUL && *name == ':')
name++;
name = skip_range(name, TRUE, NULL);

ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
ea.cmdidx = (cmdidx_T)0;
p = find_ex_command(&ea, NULL, NULL, NULL);
*** ../vim-8.2.2886/src/testdir/test_cmdline.vim 2021-05-19 17:15:00.825866111 +0200
--- src/testdir/test_cmdline.vim 2021-05-26 19:37:59.797915051 +0200
***************
*** 475,480 ****
--- 475,481 ----
for [in, want] in items(tests)
call assert_equal(want, fullcommand(in))
endfor
+ call assert_equal('', fullcommand(test_null_string()))

call assert_equal('syntax', 'syn'->fullcommand())
endfunc
*** ../vim-8.2.2886/src/version.c 2021-05-25 20:13:56.316778428 +0200
--- src/version.c 2021-05-26 19:39:00.537767384 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2887,
/**/

--
ARTHUR: A scratch? Your arm's off!
BLACK KNIGHT: No, it isn't.
ARTHUR: Well, what's that then?
BLACK KNIGHT: I've had worse.
The Quest for the Holy Grail (Monty Python)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages