mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
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.
This commit is contained in:
12
src/menu.c
12
src/menu.c
@@ -2877,13 +2877,15 @@ menuitem_getinfo(vimmenu_T *menu, int modes, dict_T *dict)
|
|||||||
int bit;
|
int bit;
|
||||||
|
|
||||||
// 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)
|
||||||
status = dict_add_string(dict, "rhs",
|
status = dict_add_string(dict, "rhs",
|
||||||
*menu->strings[bit] == NUL ?
|
*menu->strings[bit] == NUL
|
||||||
vim_strsave((char_u *)"<Nop>") :
|
? vim_strsave((char_u *)"<Nop>")
|
||||||
str2special_save(menu->strings[bit], FALSE));
|
: str2special_save(menu->strings[bit], FALSE));
|
||||||
if (status == OK)
|
if (status == OK)
|
||||||
status = dict_add_bool(dict, "noremenu",
|
status = dict_add_bool(dict, "noremenu",
|
||||||
menu->noremap[bit] == REMAP_NONE);
|
menu->noremap[bit] == REMAP_NONE);
|
||||||
@@ -2896,6 +2898,8 @@ menuitem_getinfo(vimmenu_T *menu, int modes, dict_T *dict)
|
|||||||
status = dict_add_bool(dict, "enabled",
|
status = dict_add_bool(dict, "enabled",
|
||||||
((menu->enabled & (1 << bit)) != 0));
|
((menu->enabled & (1 << bit)) != 0));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If there are submenus, add all the submenu display names
|
// If there are submenus, add all the submenu display names
|
||||||
if (status == OK && menu->children != NULL)
|
if (status == OK && menu->children != NULL)
|
||||||
{
|
{
|
||||||
|
@@ -738,6 +738,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
392,
|
||||||
/**/
|
/**/
|
||||||
391,
|
391,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user