1
0
forked from aniani/vim

patch 7.4.1654

Problem:    Crash when using expand('%:S') in a buffer without a name.
Solution:   Don't set a NUL. (James McCoy, closes #714)
This commit is contained in:
Bram Moolenaar
2016-03-25 18:42:46 +01:00
parent da64ab322a
commit 52c6eaffd4
3 changed files with 12 additions and 2 deletions

View File

@@ -26439,9 +26439,11 @@ repeat:
{ {
/* vim_strsave_shellescape() needs a NUL terminated string. */ /* vim_strsave_shellescape() needs a NUL terminated string. */
c = (*fnamep)[*fnamelen]; c = (*fnamep)[*fnamelen];
(*fnamep)[*fnamelen] = NUL; if (c != NUL)
(*fnamep)[*fnamelen] = NUL;
p = vim_strsave_shellescape(*fnamep, FALSE, FALSE); p = vim_strsave_shellescape(*fnamep, FALSE, FALSE);
(*fnamep)[*fnamelen] = c; if (c != NUL)
(*fnamep)[*fnamelen] = c;
if (p == NULL) if (p == NULL)
return -1; return -1;
vim_free(*bufp); vim_free(*bufp);

View File

@@ -41,3 +41,9 @@ func Test_fnamemodify()
call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S')) call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
set shell& set shell&
endfunc endfunc
func Test_expand()
new
call assert_equal("", expand('%:S'))
quit
endfunc

View File

@@ -748,6 +748,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 */
/**/
1654,
/**/ /**/
1653, 1653,
/**/ /**/