diff options
author | James McCoy <jamessan@jamessan.com> | 2016-03-28 09:47:46 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2016-03-30 08:30:35 -0400 |
commit | 7558f42f7d9900d37a1915ce78f1102ee251d420 (patch) | |
tree | 42b54298c1c2638a8c8c80d18a7a6c5210f8d9b7 | |
parent | 62c0d99474eb0dffcd36d227057755c16c8a9570 (diff) | |
download | rneovim-7558f42f7d9900d37a1915ce78f1102ee251d420.tar.gz rneovim-7558f42f7d9900d37a1915ce78f1102ee251d420.tar.bz2 rneovim-7558f42f7d9900d37a1915ce78f1102ee251d420.zip |
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)
https://github.com/vim/vim/commit/52c6eaffd43a8c8865f8d6ed7cde0a8b137479e2
-rw-r--r-- | src/nvim/eval.c | 8 | ||||
-rw-r--r-- | src/nvim/version.c | 1 | ||||
-rw-r--r-- | test/functional/legacy/fnamemodify_spec.lua | 11 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index fbde845f47..3c67625d1c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -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); diff --git a/src/nvim/version.c b/src/nvim/version.c index bab3d1573a..8cd0a13363 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -69,6 +69,7 @@ static char *features[] = { // clang-format off static int included_patches[] = { + 1654, 1652, 1643, 1641, diff --git a/test/functional/legacy/fnamemodify_spec.lua b/test/functional/legacy/fnamemodify_spec.lua index a439e91b6f..2a32aea127 100644 --- a/test/functional/legacy/fnamemodify_spec.lua +++ b/test/functional/legacy/fnamemodify_spec.lua @@ -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) |