To: vim_dev@googlegroups.com Subject: Patch 7.4.1654 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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) Files: src/eval.c, src/testdir/test_fnamemodify.vim *** ../vim-7.4.1653/src/eval.c 2016-03-25 15:40:45.928372939 +0100 --- src/eval.c 2016-03-25 18:40:48.626436804 +0100 *************** *** 26439,26447 **** { /* vim_strsave_shellescape() needs a NUL terminated string. */ c = (*fnamep)[*fnamelen]; ! (*fnamep)[*fnamelen] = NUL; p = vim_strsave_shellescape(*fnamep, FALSE, FALSE); ! (*fnamep)[*fnamelen] = c; if (p == NULL) return -1; vim_free(*bufp); --- 26439,26449 ---- { /* vim_strsave_shellescape() needs a NUL terminated string. */ c = (*fnamep)[*fnamelen]; ! if (c != NUL) ! (*fnamep)[*fnamelen] = NUL; p = vim_strsave_shellescape(*fnamep, FALSE, FALSE); ! if (c != NUL) ! (*fnamep)[*fnamelen] = c; if (p == NULL) return -1; vim_free(*bufp); *** ../vim-7.4.1653/src/testdir/test_fnamemodify.vim 2016-03-25 17:55:24.962112196 +0100 --- src/testdir/test_fnamemodify.vim 2016-03-25 18:39:32.979205447 +0100 *************** *** 41,43 **** --- 41,49 ---- call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S')) set shell& endfunc + + func Test_expand() + new + call assert_equal("", expand('%:S')) + quit + endfunc *** ../vim-7.4.1653/src/version.c 2016-03-25 18:34:40.550176708 +0100 --- src/version.c 2016-03-25 18:38:23.699909380 +0100 *************** *** 750,751 **** --- 750,753 ---- { /* Add new patch number below this line */ + /**/ + 1654, /**/ -- Would you care for a drink? I mean, if it were, like, disabled and you had to look after it? /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///