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.
This commit is contained in:
Justin M. Keyes 2017-01-22 21:59:54 +01:00
parent 73da522d73
commit 6be8ea0787
2 changed files with 2 additions and 1 deletions

View File

@ -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();

View File

@ -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