mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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:
parent
62c0d99474
commit
7558f42f7d
@ -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);
|
||||
|
@ -69,6 +69,7 @@ static char *features[] = {
|
||||
|
||||
// clang-format off
|
||||
static int included_patches[] = {
|
||||
1654,
|
||||
1652,
|
||||
1643,
|
||||
1641,
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user