From 33cecbbf1667cd34324e6c6e7049ede1dbff426e Mon Sep 17 00:00:00 2001 From: Eliseo Martínez Date: Fri, 13 Feb 2015 14:34:27 +0100 Subject: coverity/72768: Negative array index read: FP. Problem : Negative array index read @ 5674. Diagnostic : False positive. Rationale : Problem occurs if for loop does not find any match, which implies shl->lnum == 0, and then we enter the `if (shl->lnum == lnum)` branch, which implies lnum == 0 as well. That's not possible, as function should not be called with lnum == 0. Resolution : Change conditions `shl->lnum == lnum` into `bot != -1`. --- src/nvim/screen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/screen.c') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 80a87e9f7b..cec5753879 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5654,7 +5654,7 @@ next_search_hl_pos( continue; } if (posmatch->pos[i].lnum == lnum) { - if (shl->lnum == lnum) { + if (bot != -1) { // partially sort positions by column numbers // on the same line if (posmatch->pos[i].col < posmatch->pos[bot].col) { @@ -5670,7 +5670,7 @@ next_search_hl_pos( } } posmatch->cur = 0; - if (shl->lnum == lnum) { + if (bot != -1) { colnr_T start = posmatch->pos[bot].col == 0 ? 0: posmatch->pos[bot].col - 1; colnr_T end = posmatch->pos[bot].col == 0 -- cgit