Merge pull request #7168 from teto/fix_coverty

Closes #7149
This commit is contained in:
James McCoy 2017-08-15 19:55:24 -04:00 committed by GitHub
commit 30cb66e8ba
2 changed files with 6 additions and 5 deletions

View File

@ -19,6 +19,9 @@
#define MB_BYTE2LEN(b) utf8len_tab[b]
#define MB_BYTE2LEN_CHECK(b) (((b) < 0 || (b) > 255) ? 1 : utf8len_tab[b])
// max length of an unicode char
#define MB_MAXCHAR 6
/* properties used in enc_canon_table[] (first three mutually exclusive) */
#define ENC_8BIT 0x01
#define ENC_DBCS 0x02

View File

@ -666,8 +666,6 @@ static void free_menu_string(vimmenu_T *menu, int idx)
static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes)
{
dict_T *dict;
char buf[sizeof(menu->mnemonic)];
int mnemonic_len;
if (!menu || (menu->modes & modes) == 0x0) {
return NULL;
@ -679,8 +677,8 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes)
tv_dict_add_nr(dict, S_LEN("hidden"), menu_is_hidden(menu->dname));
if (menu->mnemonic) {
mnemonic_len = utf_char2bytes(menu->mnemonic, (u_char *)buf);
buf[mnemonic_len] = '\0';
char buf[MB_MAXCHAR + 1] = { 0 }; // > max value of utf8_char2bytes
utf_char2bytes(menu->mnemonic, (char_u *)buf);
tv_dict_add_str(dict, S_LEN("shortcut"), buf);
}
@ -717,7 +715,7 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes)
list_T *children_list = tv_list_alloc();
for (menu = menu->children; menu != NULL; menu = menu->next) {
dict_T *dic = menu_get_recursive(menu, modes);
if (dict && tv_dict_len(dict) > 0) {
if (tv_dict_len(dict) > 0) {
tv_list_append_dict(children_list, dic);
}
}