refactor(terminal): fix coverity warning (#37613)

*** CID 642984:         Null pointer dereferences  (FORWARD_NULL)
    /src/nvim/terminal.c: 571             in terminal_open()
    565
    566       if (term->sb_buffer != NULL) {
    567         // If scrollback has been allocated by autocommands between terminal_alloc()
    568         // and terminal_open(), it also needs to be refreshed.
    569         refresh_scrollback(term, buf);
    570       }
    >>>     CID 642984:         Null pointer dereferences  (FORWARD_NULL)
    >>>     Passing "term" to "refresh_screen", which dereferences null "term->sb_buffer".
    571       refresh_screen(term, buf);
    572       set_option_value(kOptBuftype, STATIC_CSTR_AS_OPTVAL("terminal"), OPT_LOCAL);
    573
    574       if (buf->b_ffname != NULL) {
    575         buf_set_term_title(buf, buf->b_ffname, strlen(buf->b_ffname));
    576       }
This commit is contained in:
zeertzjq
2026-01-29 13:16:41 +08:00
committed by GitHub
parent b40880f88f
commit 4e4e1b09d3

View File

@@ -576,6 +576,8 @@ void terminal_open(Terminal **termpp, buf_T *buf)
// If scrollback has been allocated by autocommands between terminal_alloc()
// and terminal_open(), it also needs to be refreshed.
refresh_scrollback(term, buf);
} else {
assert(term->invalid_start >= 0);
}
refresh_screen(term, buf);
set_option_value(kOptBuftype, STATIC_CSTR_AS_OPTVAL("terminal"), OPT_LOCAL);