Problem: setting buftype=terminal may cause a crash
(lacygoill, after v9.2.0127)
Solution: Validate that curwin->w_buffer->b_term is not null
fixes: #19686
closes: #19676
Signed-off-by: Christian Brabandt <cb@256bit.org>
if (name[1] == '0') // "w0": first visible line
{
#ifdef FEAT_TERMINAL
- if (bt_terminal(curwin->w_buffer))
+ if (bt_terminal(curwin->w_buffer) && curwin->w_buffer->b_term != NULL)
may_move_terminal_to_buffer(curwin->w_buffer->b_term, TRUE);
#endif
update_topline();
else if (name[1] == '$') // "w$": last visible line
{
#ifdef FEAT_TERMINAL
- if (bt_terminal(curwin->w_buffer))
+ if (bt_terminal(curwin->w_buffer) && curwin->w_buffer->b_term != NULL)
may_move_terminal_to_buffer(curwin->w_buffer->b_term, TRUE);
#endif
validate_botline();
call assert_true(str2nr(result[0]) > 1)
call StopVimInTerminal(buf)
+ " this crashed
+ new
+ setl buftype=terminal
+ call assert_equal(2, line('w0') + line('w$'))
+ bw
endfunc
" vim: shiftwidth=2 sts=2 expandtab
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 167,
/**/
166,
/**/