From bbfaa78dcdc1f4e3e7631c5ce6f4937bf932dc20 Mon Sep 17 00:00:00 2001 From: Eliseo Martínez Date: Mon, 9 Feb 2015 19:21:19 +0100 Subject: coverity/102149: Out-of-bounds access: FP. Problem : Out-of-bounds access @ 5815. Diagnostic : False positive. Rationale : Error occurs when event_name2nr() returns NUM_EVENTS, which means an event with that name was not found. That cannot happen, as previous check using find_end_event() @ 5744 ensures event name exists. Resolution : Assert event_name2nr() result is less thatn NUM_EVENTS. --- src/nvim/fileio.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/nvim/fileio.c') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 2667d13b78..a4728b245b 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -10,6 +10,7 @@ * fileio.c: read from and write to a file */ +#include #include #include #include @@ -5811,10 +5812,13 @@ void do_autocmd(char_u *arg, int forceit) nested, cmd, forceit, group) == FAIL) break; } else { - while (*arg && !vim_iswhite(*arg)) - if (do_autocmd_event(event_name2nr(arg, &arg), pat, - nested, cmd, forceit, group) == FAIL) + while (*arg && !vim_iswhite(*arg)) { + event_T event = event_name2nr(arg, &arg); + assert(event < NUM_EVENTS); + if (do_autocmd_event(event, pat, nested, cmd, forceit, group) == FAIL) { break; + } + } } if (need_free) -- cgit