vim-patch:8.2.0189: cd() with NULL argument crashes

Problem:    cd() with NULL argument crashes.
Solution:   Check for NULL. (Ken Takata, closes vim/vim#5558)
7cc96923c4
This commit is contained in:
zeertzjq 2021-10-17 22:04:53 +08:00
parent 8a2489d0a4
commit b1dd90c760
2 changed files with 3 additions and 1 deletions

View File

@ -7760,7 +7760,7 @@ bool changedir_func(char_u *new_dir, CdScope scope)
char_u *tofree;
bool retval = false;
if (allbuf_locked()) {
if (new_dir == NULL || allbuf_locked()) {
return false;
}

View File

@ -104,6 +104,8 @@ func Test_chdir_func()
call assert_fails("call chdir('dir-abcd')", 'E472:')
silent! let d = chdir("dir_abcd")
call assert_equal("", d)
" Should not crash
call chdir(d)
only | tabonly
call chdir(topdir)