To: vim-dev@vim.org Subject: Patch 7.0.054 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 7.0.054 Problem: Mac: Using a menu name that only has a mnemonic or accelerator causes a crash. (Elliot Shank) Solution: Check for an empty menu name. Also delete empty submenus that were created before detecting the error. Files: src/menu.c *** ../vim-7.0.053/src/menu.c Wed May 3 23:28:47 2006 --- src/menu.c Tue Aug 8 20:53:25 2006 *************** *** 511,516 **** --- 511,524 ---- * name (without mnemonic and accelerator text). */ next_name = menu_name_skip(name); dname = menu_text(name, NULL, NULL); + if (dname == NULL) + goto erret; + if (*dname == NUL) + { + /* Only a mnemonic or accelerator is not valid. */ + EMSG(_("E792: Empty menu name")); + goto erret; + } /* See if it's already there */ lower_pri = menup; *************** *** 704,709 **** --- 712,718 ---- parent = menu; name = next_name; vim_free(dname); + dname = NULL; if (pri_tab[pri_idx + 1] != -1) ++pri_idx; } *************** *** 793,798 **** --- 802,823 ---- erret: vim_free(path_name); vim_free(dname); + + /* Delete any empty submenu we added before discovering the error. Repeat + * for higher levels. */ + while (parent != NULL && parent->children == NULL) + { + if (parent->parent == NULL) + menup = &root_menu; + else + menup = &parent->parent->children; + for ( ; *menup != NULL && *menup != parent; menup = &((*menup)->next)) + ; + if (*menup == NULL) /* safety check */ + break; + parent = parent->parent; + free_menu(menup); + } return FAIL; } *** ../vim-7.0.053/src/version.c Tue Aug 15 22:26:04 2006 --- src/version.c Wed Aug 16 15:53:39 2006 *************** *** 668,669 **** --- 668,671 ---- { /* Add new patch number below this line */ + /**/ + 54, /**/ -- hundred-and-one symptoms of being an internet addict: 156. You forget your friend's name but not her e-mail address. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///