0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 8.2.2887: crash when passing null string to fullcommand()

Problem:    Crash when passing null string to fullcommand().
Solution:   Check for NULL pointer. (closes #8256)
This commit is contained in:
Bram Moolenaar
2021-05-26 19:49:09 +02:00
parent 34fcb69724
commit 4c8e8c6e19
3 changed files with 9 additions and 3 deletions

View File

@@ -3791,12 +3791,15 @@ f_fullcommand(typval_T *argvars, typval_T *rettv)
char_u *name = argvars[0].vval.v_string; char_u *name = argvars[0].vval.v_string;
char_u *p; char_u *p;
while (name[0] != NUL && name[0] == ':') rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
if (name == NULL)
return;
while (*name != NUL && *name == ':')
name++; name++;
name = skip_range(name, TRUE, NULL); name = skip_range(name, TRUE, NULL);
rettv->v_type = VAR_STRING;
ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
ea.cmdidx = (cmdidx_T)0; ea.cmdidx = (cmdidx_T)0;
p = find_ex_command(&ea, NULL, NULL, NULL); p = find_ex_command(&ea, NULL, NULL, NULL);

View File

@@ -475,6 +475,7 @@ func Test_fullcommand()
for [in, want] in items(tests) for [in, want] in items(tests)
call assert_equal(want, fullcommand(in)) call assert_equal(want, fullcommand(in))
endfor endfor
call assert_equal('', fullcommand(test_null_string()))
call assert_equal('syntax', 'syn'->fullcommand()) call assert_equal('syntax', 'syn'->fullcommand())
endfunc endfunc

View File

@@ -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 */
/**/
2887,
/**/ /**/
2886, 2886,
/**/ /**/