0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.3548: GTK GUI crashen when reading from stdin

Problem:    GTK GUI crashen when reading from stdin.
Solution:   Do not overwrite the NUL after the string. (closes #9028)
This commit is contained in:
Bram Moolenaar 2021-10-20 23:08:11 +01:00
parent 1d30fde3c9
commit d68a004485
3 changed files with 32 additions and 4 deletions

View File

@ -5744,11 +5744,15 @@ gui_gtk2_draw_string(int row, int col, char_u *s, int len, int flags)
}
}
if (slen < len)
{
// temporarily zero terminate substring, print, restore char, wrap
backup_ch = *(cs + slen);
*(cs + slen) = 0;
*(cs + slen) = NUL;
}
len_sum += gui_gtk2_draw_string_ext(row, col + len_sum,
cs, slen, flags, needs_pango);
if (slen < len)
*(cs + slen) = backup_ch;
cs += slen;
byte_sum += slen;

View File

@ -145,6 +145,28 @@ func Test_quoteplus()
let @+ = quoteplus_saved
endfunc
func Test_gui_read_stdin()
CheckUnix
call writefile(['some', 'lines'], 'Xstdin')
let script =<< trim END
call writefile(getline(1, '$'), 'XstdinOK')
qa!
END
call writefile(script, 'Xscript')
" Cannot use --not-a-term here, the "reading from stdin" message would not be
" displayed.
let vimcmd = substitute(GetVimCommand(), '--not-a-term', '', '')
call system('cat Xstdin | ' .. vimcmd .. ' -f -g -S Xscript -')
call assert_equal(['some', 'lines'], readfile('XstdinOK'))
call delete('Xstdin')
call delete('XstdinOK')
call delete('Xscript')
endfunc
func Test_set_background()
let background_saved = &background

View File

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