diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2015-02-09 19:21:19 +0100 |
---|---|---|
committer | Eliseo Martínez <eliseomarmol@gmail.com> | 2015-02-11 19:10:36 +0100 |
commit | bbfaa78dcdc1f4e3e7631c5ce6f4937bf932dc20 (patch) | |
tree | 4473f187297541923193b9d271438a7697c2982a /src | |
parent | 81d27d4c6bdc31c56853b2d8bd5bbd624566fb45 (diff) | |
download | rneovim-bbfaa78dcdc1f4e3e7631c5ce6f4937bf932dc20.tar.gz rneovim-bbfaa78dcdc1f4e3e7631c5ce6f4937bf932dc20.tar.bz2 rneovim-bbfaa78dcdc1f4e3e7631c5ce6f4937bf932dc20.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/fileio.c | 10 |
1 files changed, 7 insertions, 3 deletions
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 <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) |