summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-03-18 15:23:16 +0100
committerBram Moolenaar <Bram@vim.org>2020-03-18 15:23:16 +0100
commit292b90d4fa11022661f449dd3efb73d5ac737313 (patch)
tree843721ec1450241506c3ac1995bc2c32437caaf8
parenta21df1db3ca619afdcb47931af042508a6bbc8e5 (diff)
downloadvim-git-292b90d4fa11022661f449dd3efb73d5ac737313.tar.gz
patch 8.2.0399: various memory leaksv8.2.0399
Problem: Various memory leaks. Solution: Avoid the leaks. (Ozaki Kiichi, closes #5803)
-rw-r--r--src/ex_docmd.c12
-rw-r--r--src/ex_getln.c1
-rw-r--r--src/menu.c10
-rw-r--r--src/message.c1
-rw-r--r--src/scriptfile.c3
-rw-r--r--src/userfunc.c4
-rw-r--r--src/version.c2
7 files changed, 29 insertions, 4 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 58ea7c863..fb084d32d 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1346,6 +1346,18 @@ do_cmdline(
restore_dbg_stuff(&debug_saved);
msg_list = saved_msg_list;
+
+ // Cleanup if "cs_emsg_silent_list" remains.
+ if (cstack.cs_emsg_silent_list != NULL)
+ {
+ eslist_T *elem, *temp;
+
+ for (elem = cstack.cs_emsg_silent_list; elem != NULL; elem = temp)
+ {
+ temp = elem->next;
+ vim_free(elem);
+ }
+ }
#endif // FEAT_EVAL
/*
diff --git a/src/ex_getln.c b/src/ex_getln.c
index ca164cd2f..7193a2ac6 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4188,6 +4188,7 @@ open_cmdwin(void)
if (win_split((int)p_cwh, WSP_BOT) == FAIL)
{
beep_flush();
+ ga_clear(&winsizes);
return K_IGNORE;
}
cmdwin_type = get_cmdline_type();
diff --git a/src/menu.c b/src/menu.c
index 3a9d2e41f..0c8887945 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -2882,10 +2882,16 @@ menuitem_getinfo(vimmenu_T *menu, int modes, dict_T *dict)
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);
diff --git a/src/message.c b/src/message.c
index 0119145cf..fbddfadcb 100644
--- a/src/message.c
+++ b/src/message.c
@@ -865,6 +865,7 @@ emsg_namelen(char *msg, char_u *name, int len)
char_u *copy = vim_strnsave((char_u *)name, len);
semsg(msg, copy == NULL ? "NULL" : (char *)copy);
+ vim_free(copy);
}
/*
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 9c644e2b0..838d5f642 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1133,7 +1133,8 @@ do_source(
{
// Already loaded and no need to load again, return here.
*ret_sid = sid;
- return OK;
+ retval = OK;
+ goto theend;
}
#endif
diff --git a/src/userfunc.c b/src/userfunc.c
index c6c6cec3c..32b9fb5ad 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -942,6 +942,8 @@ func_clear_items(ufunc_T *fp)
ga_clear_strings(&(fp->uf_lines));
VIM_CLEAR(fp->uf_name_exp);
VIM_CLEAR(fp->uf_arg_types);
+ VIM_CLEAR(fp->uf_def_arg_idx);
+ VIM_CLEAR(fp->uf_va_name);
ga_clear(&fp->uf_type_list);
#ifdef FEAT_PROFILE
VIM_CLEAR(fp->uf_tml_count);
@@ -3086,11 +3088,11 @@ ex_function(exarg_T *eap)
erret:
ga_clear_strings(&newargs);
- ga_clear_strings(&argtypes);
ga_clear_strings(&default_args);
errret_2:
ga_clear_strings(&newlines);
ret_free:
+ ga_clear_strings(&argtypes);
vim_free(skip_until);
vim_free(line_to_free);
vim_free(fudi.fd_newkey);
diff --git a/src/version.c b/src/version.c
index 25b81882f..686e045c0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 399,
+/**/
398,
/**/
397,