]> granicus.if.org Git - vim/commitdiff
patch 8.1.1296: crash when using invalid command line argument v8.1.1296
authorBram Moolenaar <Bram@vim.org>
Wed, 8 May 2019 14:41:09 +0000 (16:41 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 8 May 2019 14:41:09 +0000 (16:41 +0200)
Problem:    Crash when using invalid command line argument.
Solution:   Check for options not being initialized.

src/term.c
src/testdir/test_startup.vim
src/version.c

index bcc3dd387233ed23e07903d140f3bb91dc98d41f..462fe6f9811cc2896ddfeb60d0e5eaa40a7862f0 100644 (file)
@@ -3014,13 +3014,13 @@ term_settitle(char_u *title)
     void
 term_push_title(int which)
 {
-    if ((which & SAVE_RESTORE_TITLE) && *T_CST != NUL)
+    if ((which & SAVE_RESTORE_TITLE) && T_CST != NULL && *T_CST != NUL)
     {
        OUT_STR(T_CST);
        out_flush();
     }
 
-    if ((which & SAVE_RESTORE_ICON) && *T_SSI != NUL)
+    if ((which & SAVE_RESTORE_ICON) && T_SSI != NULL && *T_SSI != NUL)
     {
        OUT_STR(T_SSI);
        out_flush();
@@ -3033,13 +3033,13 @@ term_push_title(int which)
     void
 term_pop_title(int which)
 {
-    if ((which & SAVE_RESTORE_TITLE) && *T_CRT != NUL)
+    if ((which & SAVE_RESTORE_TITLE) && T_CRT != NULL && *T_CRT != NUL)
     {
        OUT_STR(T_CRT);
        out_flush();
     }
 
-    if ((which & SAVE_RESTORE_ICON) && *T_SRI != NUL)
+    if ((which & SAVE_RESTORE_ICON) && T_SRI != NULL && *T_SRI != NUL)
     {
        OUT_STR(T_SRI);
        out_flush();
index dec485b1388454b35141234203caf8c49fe53be2..a45130f7a7edf165a3a39ace6b9712ee0278f645 100644 (file)
@@ -408,12 +408,11 @@ func Test_invalid_args()
   endfor
 
   if has('clientserver')
-    " FIXME: need to add --servername to this list
-    " but it causes vim-8.1.1282 to crash!
     for opt in ['--remote', '--remote-send', '--remote-silent', '--remote-expr',
           \     '--remote-tab', '--remote-tab-wait',
           \     '--remote-tab-wait-silent', '--remote-tab-silent',
           \     '--remote-wait', '--remote-wait-silent',
+          \     '--servername',
           \    ]
       let out = split(system(GetVimCommand() .. ' '  .. opt), "\n")
       call assert_equal(1, v:shell_error)
@@ -423,14 +422,13 @@ func Test_invalid_args()
     endfor
   endif
 
-  " FIXME: commented out as this causes vim-8.1.1282 to crash!
-  "if has('clipboard')
-  "  let out = split(system(GetVimCommand() .. ' --display'), "\n")
-  "  call assert_equal(1, v:shell_error)
-  "  call assert_match('^VIM - Vi IMproved .* (.*)$',         out[0])
-  "  call assert_equal('Argument missing after: "--display"', out[1])
-  "  call assert_equal('More info with: "vim -h"',            out[2])
-  "endif
+  if has('clipboard')
+    let out = split(system(GetVimCommand() .. ' --display'), "\n")
+    call assert_equal(1, v:shell_error)
+    call assert_match('^VIM - Vi IMproved .* (.*)$',         out[0])
+    call assert_equal('Argument missing after: "--display"', out[1])
+    call assert_equal('More info with: "vim -h"',            out[2])
+  endif
 
   let out = split(system(GetVimCommand() .. ' -ix'), "\n")
   call assert_equal(1, v:shell_error)
@@ -463,16 +461,15 @@ func Test_invalid_args()
     call assert_equal('More info with: "vim -h"',                                       out[2])
   endfor
 
-  " FIXME: commented out as this causes vim-8.1.1282 to crash!
-  "if has('gui_gtk')
-  "  for opt in ['--socketid x', '--socketid 0xg']
-  "    let out = split(system(GetVimCommand() .. ' ' .. opt), "\n")
-  "    call assert_equal(1, v:shell_error)
-  "    call assert_match('^VIM - Vi IMproved .* (.*)$',        out[0])
-  "    call assert_equal('Invalid argument for: "--socketid"', out[1])
-  "    call assert_equal('More info with: "vim -h"',           out[2])
-  "  endfor
-  "endif
+  if has('gui_gtk')
+    for opt in ['--socketid x', '--socketid 0xg']
+      let out = split(system(GetVimCommand() .. ' ' .. opt), "\n")
+      call assert_equal(1, v:shell_error)
+      call assert_match('^VIM - Vi IMproved .* (.*)$',        out[0])
+      call assert_equal('Invalid argument for: "--socketid"', out[1])
+      call assert_equal('More info with: "vim -h"',           out[2])
+    endfor
+  endif
 endfunc
 
 func Test_file_args()
index 32066b4f6156c5b5cf90adfeb784a3d8925f876b..8e6b404f8bc321b9bfbb7cd4709841d5efad5cde 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1296,
 /**/
     1295,
 /**/