diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-01-22 21:59:54 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-01-23 15:49:37 +0100 |
commit | 6be8ea07872ac8badd3645a51017c32b0b90d59e (patch) | |
tree | c5dfe65972d33e0d65deb5daaf291eb9be35d63c | |
parent | 73da522d73c5d686c122ea4482d03e576a6a242c (diff) | |
download | rneovim-6be8ea07872ac8badd3645a51017c32b0b90d59e.tar.gz rneovim-6be8ea07872ac8badd3645a51017c32b0b90d59e.tar.bz2 rneovim-6be8ea07872ac8badd3645a51017c32b0b90d59e.zip |
coverity/133845: Negative array index read. (FP)
`find_command(s->ca.cmdchar) >= 0` was established near the start of
normal_execute(). And `unshift_special(&s->ca);` "should" not ever
result in s->ca.cmdchar containing a multibyte char.
So only an assert() is needed here.
-rw-r--r-- | src/nvim/normal.c | 1 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 9db02de2a6..b17b4c584e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1130,6 +1130,7 @@ static int normal_execute(VimState *state, int key) start_selection(); unshift_special(&s->ca); s->idx = find_command(s->ca.cmdchar); + assert(s->idx >= 0); } else if ((nv_cmds[s->idx].cmd_flags & NV_SSS) && (mod_mask & MOD_MASK_SHIFT)) { start_selection(); diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index bb82f11a58..54f43387dc 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -613,7 +613,7 @@ function Screen:_pprint_attrs(attrs) return table.concat(items, ", ") end -function backward_find_meaningful(tbl, from) -- luacheck: ignore +local function backward_find_meaningful(tbl, from) -- luacheck: no unused for i = from or #tbl, 1, -1 do if tbl[i] ~= ' ' then return i + 1 |