Mercurial > vim
diff src/menu.c @ 19685:d64f403289db v8.2.0399
patch 8.2.0399: various memory leaks
Commit: https://github.com/vim/vim/commit/292b90d4fa11022661f449dd3efb73d5ac737313
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 18 15:23:16 2020 +0100
patch 8.2.0399: various memory leaks
Problem: Various memory leaks.
Solution: Avoid the leaks. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/5803)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 18 Mar 2020 15:30:04 +0100 |
parents | 897cb43a5c72 |
children | 3ff714d765ba |
line wrap: on
line diff
--- a/src/menu.c +++ b/src/menu.c @@ -2882,10 +2882,16 @@ menuitem_getinfo(vimmenu_T *menu, int mo if (bit < MENU_MODES) // just in case, avoid Coverity warning { if (menu->strings[bit] != NULL) + { + char_u *tofree = NULL; + status = dict_add_string(dict, "rhs", *menu->strings[bit] == NUL - ? vim_strsave((char_u *)"<Nop>") - : str2special_save(menu->strings[bit], FALSE)); + ? (char_u *)"<Nop>" + : (tofree = str2special_save( + menu->strings[bit], FALSE))); + vim_free(tofree); + } if (status == OK) status = dict_add_bool(dict, "noremenu", menu->noremap[bit] == REMAP_NONE);