patch 8.2.0399: various memory leaks
Problem: Various memory leaks.
Solution: Avoid the leaks. (Ozaki Kiichi, closes #5803)
diff --git a/src/menu.c b/src/menu.c
index 3a9d2e4..0c88879 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -2882,10 +2882,16 @@
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);