Patch 8.2.3548

5 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 20, 2021, 6:08:58 PM10/20/21
to vim...@googlegroups.com

Patch 8.2.3548
Problem: GTK GUI crashen when reading from stdin.
Solution: Do not overwrite the NUL after the string. (closes #9028)
Files: src/gui_gtk_x11.c, src/testdir/test_gui.vim


*** ../vim-8.2.3547/src/gui_gtk_x11.c 2021-10-17 11:33:44.510907324 +0100
--- src/gui_gtk_x11.c 2021-10-20 22:59:39.042952945 +0100
***************
*** 5744,5755 ****
}
}

! // temporarily zero terminate substring, print, restore char, wrap
! backup_ch = *(cs + slen);
! *(cs + slen) = 0;
len_sum += gui_gtk2_draw_string_ext(row, col + len_sum,
cs, slen, flags, needs_pango);
! *(cs + slen) = backup_ch;
cs += slen;
byte_sum += slen;
needs_pango = should_need_pango;
--- 5744,5759 ----
}
}

! if (slen < len)
! {
! // temporarily zero terminate substring, print, restore char, wrap
! backup_ch = *(cs + slen);
! *(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;
needs_pango = should_need_pango;
*** ../vim-8.2.3547/src/testdir/test_gui.vim 2021-10-16 21:58:23.206049605 +0100
--- src/testdir/test_gui.vim 2021-10-20 23:07:21.117941680 +0100
***************
*** 145,150 ****
--- 145,172 ----
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

*** ../vim-8.2.3547/src/version.c 2021-10-20 21:58:37.239792741 +0100
--- src/version.c 2021-10-20 22:23:11.371189464 +0100
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3548,
/**/

--
Your mouse has moved. Windows must be restarted for the change
to take effect. Reboot now?

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages