diff --git a/src/eval.c b/src/eval.c index 770879661c..225658921c 100644 --- a/src/eval.c +++ b/src/eval.c @@ -26439,9 +26439,11 @@ repeat: { /* vim_strsave_shellescape() needs a NUL terminated string. */ c = (*fnamep)[*fnamelen]; - (*fnamep)[*fnamelen] = NUL; + if (c != NUL) + (*fnamep)[*fnamelen] = NUL; p = vim_strsave_shellescape(*fnamep, FALSE, FALSE); - (*fnamep)[*fnamelen] = c; + if (c != NUL) + (*fnamep)[*fnamelen] = c; if (p == NULL) return -1; vim_free(*bufp); diff --git a/src/testdir/test_fnamemodify.vim b/src/testdir/test_fnamemodify.vim index 902be40dcd..2267e18e3b 100644 --- a/src/testdir/test_fnamemodify.vim +++ b/src/testdir/test_fnamemodify.vim @@ -41,3 +41,9 @@ func Test_fnamemodify() call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S')) set shell& endfunc + +func Test_expand() + new + call assert_equal("", expand('%:S')) + quit +endfunc diff --git a/src/version.c b/src/version.c index 1e8c41964e..c1f6db6278 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1654, /**/ 1653, /**/