vim-patch:9.1.0341: Problem: a few memory leaks are found (#28382)

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

29269a71b5

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq 2024-04-17 06:52:29 +08:00 committed by GitHub
parent 0b2b1b0185
commit 2f371ad7d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -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;
@ -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;
}

View File

@ -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