neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 4e4e1b09d30523076f3841a2c65d7ddcd9c481c4
parent b40880f88ffb5efb636b001faed6241a1cae91f7
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Thu, 29 Jan 2026 13:16:41 +0800

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       }
Diffstat:
Msrc/nvim/terminal.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c @@ -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);