From e5d388f23a6809ba2bd600e813f2a4b0bdbd20c8 Mon Sep 17 00:00:00 2001 From: Ihor Antonov Date: Sun, 11 Aug 2019 03:47:49 -0400 Subject: clang/"Argument with 'nonnull' attribute passed null" #10739 Problem: In screen.c grid_char_needs_redraw clang warns that grid->chars could be NULL Solution: Suggested by bfredl. Add explicit check grid->chars != NULL in grid_put_linebuf similar to grid_puts_len --- src/nvim/screen.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index e2dee154df..99ccce1793 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -4374,6 +4374,12 @@ static void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, screen_adjust_grid(&grid, &row, &coloff); + // Safety check. Avoids clang warnings down the call stack. + if (grid->chars == NULL || row >= grid->Rows || col >= grid->Columns) { + DLOG("invalid state, skipped"); + return; + } + off_from = 0; off_to = grid->line_offset[row] + coloff; max_off_from = linebuf_size; -- cgit