0
0
mirror of https://github.com/vim/vim.git synced 2025-10-08 06:04:08 -04:00

patch 8.1.1296: crash when using invalid command line argument

Problem:    Crash when using invalid command line argument.
Solution:   Check for options not being initialized.
This commit is contained in:
Bram Moolenaar
2019-05-08 16:41:09 +02:00
parent 98ffe4c6d8
commit 27821260c0
3 changed files with 23 additions and 24 deletions

View File

@@ -3014,13 +3014,13 @@ term_settitle(char_u *title)
void void
term_push_title(int which) 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_STR(T_CST);
out_flush(); 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_STR(T_SSI);
out_flush(); out_flush();
@@ -3033,13 +3033,13 @@ term_push_title(int which)
void void
term_pop_title(int which) 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_STR(T_CRT);
out_flush(); 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_STR(T_SRI);
out_flush(); out_flush();

View File

@@ -408,12 +408,11 @@ func Test_invalid_args()
endfor endfor
if has('clientserver') 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', for opt in ['--remote', '--remote-send', '--remote-silent', '--remote-expr',
\ '--remote-tab', '--remote-tab-wait', \ '--remote-tab', '--remote-tab-wait',
\ '--remote-tab-wait-silent', '--remote-tab-silent', \ '--remote-tab-wait-silent', '--remote-tab-silent',
\ '--remote-wait', '--remote-wait-silent', \ '--remote-wait', '--remote-wait-silent',
\ '--servername',
\ ] \ ]
let out = split(system(GetVimCommand() .. ' ' .. opt), "\n") let out = split(system(GetVimCommand() .. ' ' .. opt), "\n")
call assert_equal(1, v:shell_error) call assert_equal(1, v:shell_error)
@@ -423,14 +422,13 @@ func Test_invalid_args()
endfor endfor
endif endif
" FIXME: commented out as this causes vim-8.1.1282 to crash! if has('clipboard')
"if has('clipboard') let out = split(system(GetVimCommand() .. ' --display'), "\n")
" let out = split(system(GetVimCommand() .. ' --display'), "\n") call assert_equal(1, v:shell_error)
" call assert_equal(1, v:shell_error) call assert_match('^VIM - Vi IMproved .* (.*)$', out[0])
" call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) call assert_equal('Argument missing after: "--display"', out[1])
" call assert_equal('Argument missing after: "--display"', out[1]) call assert_equal('More info with: "vim -h"', out[2])
" call assert_equal('More info with: "vim -h"', out[2]) endif
"endif
let out = split(system(GetVimCommand() .. ' -ix'), "\n") let out = split(system(GetVimCommand() .. ' -ix'), "\n")
call assert_equal(1, v:shell_error) 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]) call assert_equal('More info with: "vim -h"', out[2])
endfor endfor
" FIXME: commented out as this causes vim-8.1.1282 to crash! if has('gui_gtk')
"if has('gui_gtk') for opt in ['--socketid x', '--socketid 0xg']
" for opt in ['--socketid x', '--socketid 0xg'] let out = split(system(GetVimCommand() .. ' ' .. opt), "\n")
" let out = split(system(GetVimCommand() .. ' ' .. opt), "\n") call assert_equal(1, v:shell_error)
" call assert_equal(1, v:shell_error) call assert_match('^VIM - Vi IMproved .* (.*)$', out[0])
" call assert_match('^VIM - Vi IMproved .* (.*)$', out[0]) call assert_equal('Invalid argument for: "--socketid"', out[1])
" call assert_equal('Invalid argument for: "--socketid"', out[1]) call assert_equal('More info with: "vim -h"', out[2])
" call assert_equal('More info with: "vim -h"', out[2]) endfor
" endfor endif
"endif
endfunc endfunc
func Test_file_args() func Test_file_args()

View File

@@ -767,6 +767,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1296,
/**/ /**/
1295, 1295,
/**/ /**/