mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 14:26:07 +00:00
vim-patch:8.2.0392: Coverity warns for using array index out of range
Problem: Coverity warns for using array index out of range.
Solution: Add extra "if" to avoid warning.
56cb337872
This commit is contained in:
@@ -1913,6 +1913,7 @@ static void menuitem_getinfo(const vimmenu_T *menu, int modes, dict_T *dict)
|
|||||||
// Get the first mode in which the menu is available
|
// Get the first mode in which the menu is available
|
||||||
for (bit = 0; (bit < MENU_MODES) && !((1 << bit) & modes); bit++) {}
|
for (bit = 0; (bit < MENU_MODES) && !((1 << bit) & modes); bit++) {}
|
||||||
|
|
||||||
|
if (bit < MENU_MODES) { // just in case, avoid Coverity warning
|
||||||
if (menu->strings[bit] != NULL) {
|
if (menu->strings[bit] != NULL) {
|
||||||
tv_dict_add_allocated_str(dict, S_LEN("rhs"),
|
tv_dict_add_allocated_str(dict, S_LEN("rhs"),
|
||||||
*menu->strings[bit] == NUL
|
*menu->strings[bit] == NUL
|
||||||
@@ -1923,6 +1924,7 @@ static void menuitem_getinfo(const vimmenu_T *menu, int modes, dict_T *dict)
|
|||||||
tv_dict_add_bool(dict, S_LEN("script"), menu->noremap[bit] == REMAP_SCRIPT);
|
tv_dict_add_bool(dict, S_LEN("script"), menu->noremap[bit] == REMAP_SCRIPT);
|
||||||
tv_dict_add_bool(dict, S_LEN("silent"), menu->silent[bit]);
|
tv_dict_add_bool(dict, S_LEN("silent"), menu->silent[bit]);
|
||||||
tv_dict_add_bool(dict, S_LEN("enabled"), (menu->enabled & (1 << bit)) != 0);
|
tv_dict_add_bool(dict, S_LEN("enabled"), (menu->enabled & (1 << bit)) != 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// If there are submenus, add all the submenu display names
|
// If there are submenus, add all the submenu display names
|
||||||
list_T *const l = tv_list_alloc(kListLenMayKnow);
|
list_T *const l = tv_list_alloc(kListLenMayKnow);
|
||||||
|
Reference in New Issue
Block a user