Skip to content

Commit

Permalink
vim-patch:9.1.0341: Problem: a few memory leaks are found (#28382)
Browse files Browse the repository at this point in the history
Problem:  a few memory leaks are found
          (LuMingYinDetect )
Solution: properly free the memory

Fixes the following problems:
- Memory leak in f_maplist()
  fixes: vim/vim#14486

- Memory leak in option.c
  fixes: vim/vim#14485

- Memory leak in f_resolve()
  fixes: vim/vim#14484

- Memory leak in f_autocmd_get()
  related: vim/vim#14474

- Memory leak in dict_extend_func()
  fixes: vim/vim#14477
  fixes: vim/vim#14238

closes: vim/vim#14517

vim/vim@29269a7

Co-authored-by: Christian Brabandt <cb@256bit.org>
  • Loading branch information
zeertzjq and chrisbra committed Apr 16, 2024
1 parent 0b2b1b0 commit 2f371ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/nvim/eval/funcs.c
Expand Up @@ -2019,6 +2019,9 @@ static void extend_dict(typval_T *argvars, const char *arg_errmsg, bool is_new,

action = tv_get_string_chk(&argvars[2]);
if (action == NULL) {
if (is_new) {
tv_dict_unref(d1);
}
return; // Type error; error message already given.
}
size_t i;
Expand All @@ -2028,6 +2031,9 @@ static void extend_dict(typval_T *argvars, const char *arg_errmsg, bool is_new,
}
}
if (i == 3) {
if (is_new) {
tv_dict_unref(d1);
}
semsg(_(e_invarg2), action);
return;
}
Expand Down
6 changes: 6 additions & 0 deletions test/old/testdir/test_listdict.vim
Expand Up @@ -1441,4 +1441,10 @@ func Test_indexof()
delfunc TestIdx
endfunc

func Test_extendnew_leak()
" This used to leak memory
for i in range(100) | silent! call extendnew([], [], []) | endfor
for i in range(100) | silent! call extendnew({}, {}, {}) | endfor
endfunc

" vim: shiftwidth=2 sts=2 expandtab

0 comments on commit 2f371ad

Please sign in to comment.