diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2015-02-13 14:34:27 +0100 |
---|---|---|
committer | Eliseo Martínez <eliseomarmol@gmail.com> | 2015-02-20 17:34:07 +0100 |
commit | 33cecbbf1667cd34324e6c6e7049ede1dbff426e (patch) | |
tree | 1b2a2502df9d50938c6d398b16bc6bcaf3fc5c0b | |
parent | 03dd2114a78f513c362ccc5ec4de700f11a2db0e (diff) | |
download | rneovim-33cecbbf1667cd34324e6c6e7049ede1dbff426e.tar.gz rneovim-33cecbbf1667cd34324e6c6e7049ede1dbff426e.tar.bz2 rneovim-33cecbbf1667cd34324e6c6e7049ede1dbff426e.zip |
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`.
-rw-r--r-- | src/nvim/screen.c | 4 |
1 files changed, 2 insertions, 2 deletions
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 |