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.
This commit is contained in:
Eliseo Martínez 2015-02-09 19:21:19 +01:00
parent 81d27d4c6b
commit bbfaa78dcd

View File

@ -10,6 +10,7 @@
* fileio.c: read from and write to a file
*/
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <string.h>
@ -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)