mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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`.
This commit is contained in:
parent
03dd2114a7
commit
33cecbbf16
@ -5654,7 +5654,7 @@ next_search_hl_pos(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (posmatch->pos[i].lnum == lnum) {
|
if (posmatch->pos[i].lnum == lnum) {
|
||||||
if (shl->lnum == lnum) {
|
if (bot != -1) {
|
||||||
// partially sort positions by column numbers
|
// partially sort positions by column numbers
|
||||||
// on the same line
|
// on the same line
|
||||||
if (posmatch->pos[i].col < posmatch->pos[bot].col) {
|
if (posmatch->pos[i].col < posmatch->pos[bot].col) {
|
||||||
@ -5670,7 +5670,7 @@ next_search_hl_pos(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
posmatch->cur = 0;
|
posmatch->cur = 0;
|
||||||
if (shl->lnum == lnum) {
|
if (bot != -1) {
|
||||||
colnr_T start = posmatch->pos[bot].col == 0
|
colnr_T start = posmatch->pos[bot].col == 0
|
||||||
? 0: posmatch->pos[bot].col - 1;
|
? 0: posmatch->pos[bot].col - 1;
|
||||||
colnr_T end = posmatch->pos[bot].col == 0
|
colnr_T end = posmatch->pos[bot].col == 0
|
||||||
|
Loading…
Reference in New Issue
Block a user