comparison src/menu.c @ 19671:897cb43a5c72 v8.2.0392

patch 8.2.0392: Coverity warns for using array index out of range Commit: https://github.com/vim/vim/commit/56cb3378727783da2d246b9c5091784821666cfa Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 16 20:04:41 2020 +0100 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.
author Bram Moolenaar <Bram@vim.org>
date Mon, 16 Mar 2020 20:15:04 +0100
parents da791e5c0139
children d64f403289db
comparison
equal deleted inserted replaced
19670:00e4b686ae2b 19671:897cb43a5c72
2875 if (status == OK && menu->children == NULL) 2875 if (status == OK && menu->children == NULL)
2876 { 2876 {
2877 int bit; 2877 int bit;
2878 2878
2879 // Get the first mode in which the menu is available 2879 // Get the first mode in which the menu is available
2880 for (bit = 0; (bit < MENU_MODES) && !((1 << bit) & modes); bit++) 2880 for (bit = 0; bit < MENU_MODES && !((1 << bit) & modes); bit++)
2881 ; 2881 ;
2882 if (menu->strings[bit] != NULL) 2882 if (bit < MENU_MODES) // just in case, avoid Coverity warning
2883 status = dict_add_string(dict, "rhs", 2883 {
2884 *menu->strings[bit] == NUL ? 2884 if (menu->strings[bit] != NULL)
2885 vim_strsave((char_u *)"<Nop>") : 2885 status = dict_add_string(dict, "rhs",
2886 str2special_save(menu->strings[bit], FALSE)); 2886 *menu->strings[bit] == NUL
2887 if (status == OK) 2887 ? vim_strsave((char_u *)"<Nop>")
2888 status = dict_add_bool(dict, "noremenu", 2888 : str2special_save(menu->strings[bit], FALSE));
2889 menu->noremap[bit] == REMAP_NONE); 2889 if (status == OK)
2890 if (status == OK) 2890 status = dict_add_bool(dict, "noremenu",
2891 status = dict_add_bool(dict, "script", 2891 menu->noremap[bit] == REMAP_NONE);
2892 menu->noremap[bit] == REMAP_SCRIPT); 2892 if (status == OK)
2893 if (status == OK) 2893 status = dict_add_bool(dict, "script",
2894 status = dict_add_bool(dict, "silent", menu->silent[bit]); 2894 menu->noremap[bit] == REMAP_SCRIPT);
2895 if (status == OK) 2895 if (status == OK)
2896 status = dict_add_bool(dict, "enabled", 2896 status = dict_add_bool(dict, "silent", menu->silent[bit]);
2897 ((menu->enabled & (1 << bit)) != 0)); 2897 if (status == OK)
2898 } 2898 status = dict_add_bool(dict, "enabled",
2899 ((menu->enabled & (1 << bit)) != 0));
2900 }
2901 }
2902
2899 // If there are submenus, add all the submenu display names 2903 // If there are submenus, add all the submenu display names
2900 if (status == OK && menu->children != NULL) 2904 if (status == OK && menu->children != NULL)
2901 { 2905 {
2902 list_T *l = list_alloc(); 2906 list_T *l = list_alloc();
2903 vimmenu_T *child; 2907 vimmenu_T *child;