]> granicus.if.org Git - vim/commitdiff
patch 8.2.0232: the :compiler command causes a crash v8.2.0232
authorBram Moolenaar <Bram@vim.org>
Sat, 8 Feb 2020 15:00:46 +0000 (16:00 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 8 Feb 2020 15:00:46 +0000 (16:00 +0100)
Problem:    The :compiler command causes a crash. (Daniel Steinberg)
Solution:   Do not use the script index if it isn't set.

src/ex_docmd.c
src/testdir/test_compiler.vim
src/version.c

index 645ad0c93c8a9f6f335540b6fb94cd558e3852cc..659af19111dcd7af627b55cdd84bacc1c6587e11 100644 (file)
@@ -2495,7 +2495,8 @@ do_one_cmd(
 
 #ifdef FEAT_EVAL
     // Set flag that any command was executed, used by ex_vim9script().
-    if (getline_equal(ea.getline, ea.cookie, getsourceline))
+    if (getline_equal(ea.getline, ea.cookie, getsourceline)
+                                                   && current_sctx.sc_sid > 0)
        SCRIPT_ITEM(current_sctx.sc_sid)->sn_had_command = TRUE;
 
     /*
index 4f02cf1c2f9642afc81b986b1c462788dbe3735a..464dd9bcb5a6243f4c19f659675d5c7be9405a01 100644 (file)
@@ -1,6 +1,7 @@
 " Test the :compiler command
 
 source check.vim
+source shared.vim
 
 func Test_compiler()
   if !executable('perl')
@@ -48,6 +49,15 @@ func Test_compiler_without_arg()
   call assert_match(runtime .. '/compiler/xmlwf.vim$', a[-1])
 endfunc
 
+" Test executing :compiler from the command line, not from a script
+func Test_compiler_commandline()
+  call system(GetVimCommandClean() .. ' --not-a-term -c "compiler gcc" -c "call writefile([b:current_compiler], ''XcompilerOut'')" -c "quit"')
+  call assert_equal(0, v:shell_error)
+  call assert_equal(["gcc"], readfile('XcompilerOut'))
+
+  call delete('XcompilerOut')
+endfunc
+
 func Test_compiler_completion()
   call feedkeys(":compiler \<C-A>\<C-B>\"\<CR>", 'tx')
   call assert_match('^"compiler ant bcc .* xmlwf$', @:)
index db1f9f77b7b9358ad93431134837aa15184b1a07..e1fde105f99ba3c86cf0f7d81250c7a88877f20a 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    232,
 /**/
     231,
 /**/