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 vim/vim#714)

52c6eaffd4
This commit is contained in:
James McCoy 2016-03-28 09:47:46 -04:00
parent 62c0d99474
commit 7558f42f7d
3 changed files with 18 additions and 2 deletions

View File

@ -21995,9 +21995,13 @@ repeat:
if (src[*usedlen] == ':' && src[*usedlen + 1] == 'S') {
// 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;
}
xfree(*bufp);
*bufp = *fnamep = p;
*fnamelen = STRLEN(p);

View File

@ -69,6 +69,7 @@ static char *features[] = {
// clang-format off
static int included_patches[] = {
1654,
1652,
1643,
1641,

View File

@ -54,6 +54,12 @@ describe('filename modifiers', function()
set shell=tcsh
call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
endfunc
func Test_expand()
new
call assert_equal("", expand('%:S'))
quit
endfunc
]=])
end)
@ -61,4 +67,9 @@ describe('filename modifiers', function()
call('Test_fnamemodify')
expected_empty()
end)
it('works for :S in an unnamed buffer', function()
call('Test_expand')
expected_empty()
end)
end)