]> granicus.if.org Git - vim/commitdiff
patch 9.0.1332: crash when using buffer-local user command in cmdline window v9.0.1332
authorzeertzjq <zeertzjq@outlook.com>
Mon, 20 Feb 2023 15:25:13 +0000 (15:25 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 20 Feb 2023 15:25:13 +0000 (15:25 +0000)
Problem:    Crash when using buffer-local user command in cmdline window.
            (Karl Yngve LervĂ„g)
Solution:   Use the right buffer to find the user command. (closes #12030,
            closes #12029)

src/testdir/test_usercommands.vim
src/usercmd.c
src/version.c

index d8b4cb40e0ef4822d6b67bed23611165afc2db7a..1e1856727a78ca145a381b4691df95daacfc9806 100644 (file)
@@ -856,6 +856,15 @@ func Test_buflocal_ambiguous_usercmd()
   bw!
 endfunc
 
+" Test for using buffer-local user command from cmdwin.
+func Test_buflocal_usercmd_cmdwin()
+  new
+  command -buffer TestCmd edit Test
+  " This used to crash Vim
+  call assert_fails("norm q::TestCmd\<CR>", 'E11:')
+  bw!
+endfunc
+
 " Test for using a multibyte character in a user command
 func Test_multibyte_in_usercmd()
   command SubJapanesePeriodToDot exe "%s/\u3002/./g"
index 44fa578f695a8f31bdb721b0f24192e929995b73..7d844620bdae78033f0cdc4e1f8276d38e6d149b 100644 (file)
@@ -1838,7 +1838,7 @@ do_ucmd(exarg_T *eap)
     if (eap->cmdidx == CMD_USER)
        cmd = USER_CMD(eap->useridx);
     else
-       cmd = USER_CMD_GA(&curbuf->b_ucmds, eap->useridx);
+       cmd = USER_CMD_GA(&prevwin_curwin()->w_buffer->b_ucmds, eap->useridx);
 
     /*
      * Replace <> in the command by the arguments.
index 4c1282327573d2ab7de99184256bb62e09b75207..0095489c7ecf3f34a0359767fa71f7e62402c8bf 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1332,
 /**/
     1331,
 /**/