changeset 9902:5a667a3a3743 v7.4.2225

commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 17 22:29:09 2016 +0200 patch 7.4.2225 Problem: Crash when placing a sign in a deleted buffer. Solution: Check for missing buffer name. (Dominique Pelle). Add a test.
author Christian Brabandt <cb@256bit.org>
date Wed, 17 Aug 2016 22:30:06 +0200
parents c6b969706678
children fee4b54981cd
files src/ex_cmds.c src/testdir/test_signs.vim src/version.c
diffstat 3 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -7861,6 +7861,11 @@ ex_sign(exarg_T *eap)
 		{			/* ... not currently in a window */
 		    char_u	*cmd;
 
+		    if (buf->b_fname == NULL)
+		    {
+			EMSG(_("E934: Cannot jump to a buffer that does not have a name"));
+			return;
+		    }
 		    cmd = alloc((unsigned)STRLEN(buf->b_fname) + 25);
 		    if (cmd == NULL)
 			return;
--- a/src/testdir/test_signs.vim
+++ b/src/testdir/test_signs.vim
@@ -181,3 +181,15 @@ func Test_sign_invalid_commands()
   call assert_fails('sign place 1 buffer=', 'E158:')
   call assert_fails('sign define Sign2 text=', 'E239:')
 endfunc
+
+func Test_sign_delete_buffer()
+  new
+  sign define Sign text=x
+  let bufnr = bufnr('%')
+  new
+  exe 'bd ' . bufnr
+  exe 'sign place 61 line=3 name=Sign buffer=' . bufnr
+  call assert_fails('sign jump 61 buffer=' . bufnr, 'E934:')
+  sign unplace 61
+  sign undefine Sign
+endfunc
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2225,
+/**/
     2224,
 /**/
     2223,