]> granicus.if.org Git - vim/commitdiff
patch 7.4.1654 v7.4.1654
authorBram Moolenaar <Bram@vim.org>
Fri, 25 Mar 2016 17:42:46 +0000 (18:42 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 25 Mar 2016 17:42:46 +0000 (18:42 +0100)
Problem:    Crash when using expand('%:S') in a buffer without a name.
Solution:   Don't set a NUL. (James McCoy, closes #714)

src/eval.c
src/testdir/test_fnamemodify.vim
src/version.c

index 770879661cd08fdf348e868def8e1eeb435f7ed9..225658921c09c1235b614826d5dd88aa24f898af 100644 (file)
@@ -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);
index 902be40dcdf8476158a0768778aabcea85ae3aa8..2267e18e3be0e5c01031cc0c9852ff7084cda82d 100644 (file)
@@ -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
index 1e8c41964ec80d85840169a65ba44dfc22e7a773..c1f6db6278c1a6398d59ca5711621567e94677ac 100644 (file)
@@ -748,6 +748,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1654,
 /**/
     1653,
 /**/