To: vim_dev@googlegroups.com Subject: Patch 8.2.0392 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0392 Problem: Coverity warns for using array index out of range. Solution: Add extra "if" to avoid warning. Files: src/menu.c *** ../vim-8.2.0391/src/menu.c 2020-03-15 16:12:16.552208654 +0100 --- src/menu.c 2020-03-16 20:04:32.980471725 +0100 *************** *** 2877,2901 **** int bit; // Get the first mode in which the menu is available ! for (bit = 0; (bit < MENU_MODES) && !((1 << bit) & modes); bit++) ; ! if (menu->strings[bit] != NULL) ! status = dict_add_string(dict, "rhs", ! *menu->strings[bit] == NUL ? ! vim_strsave((char_u *)"") : ! str2special_save(menu->strings[bit], FALSE)); ! if (status == OK) ! status = dict_add_bool(dict, "noremenu", ! menu->noremap[bit] == REMAP_NONE); ! if (status == OK) ! status = dict_add_bool(dict, "script", ! menu->noremap[bit] == REMAP_SCRIPT); ! if (status == OK) ! status = dict_add_bool(dict, "silent", menu->silent[bit]); ! if (status == OK) ! status = dict_add_bool(dict, "enabled", ! ((menu->enabled & (1 << bit)) != 0)); } // If there are submenus, add all the submenu display names if (status == OK && menu->children != NULL) { --- 2877,2905 ---- int bit; // Get the first mode in which the menu is available ! 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) ! status = dict_add_string(dict, "rhs", ! *menu->strings[bit] == NUL ! ? vim_strsave((char_u *)"") ! : str2special_save(menu->strings[bit], FALSE)); ! if (status == OK) ! status = dict_add_bool(dict, "noremenu", ! menu->noremap[bit] == REMAP_NONE); ! if (status == OK) ! status = dict_add_bool(dict, "script", ! menu->noremap[bit] == REMAP_SCRIPT); ! if (status == OK) ! status = dict_add_bool(dict, "silent", menu->silent[bit]); ! if (status == OK) ! status = dict_add_bool(dict, "enabled", ! ((menu->enabled & (1 << bit)) != 0)); ! } } + // If there are submenus, add all the submenu display names if (status == OK && menu->children != NULL) { *** ../vim-8.2.0391/src/version.c 2020-03-16 12:09:27.344858944 +0100 --- src/version.c 2020-03-16 20:02:18.236980498 +0100 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 392, /**/ -- "Time flies like an arrow". So I put an arrow on my desk, now awaiting one of these time flies showing up. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///