mirror of
https://github.com/neovim/neovim.git
synced 2025-11-16 15:21:20 +00:00
vim-patch:9.0.1142: crash and/or memory leak when redefining function
Problem: Crash and/or memory leak when redefining function after error.
Solution: Clear pointer after making a copy. Clear arrays on failure.
(closes vim/vim#11774)
f057171d8b
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -2918,13 +2918,14 @@ void ex_function(exarg_T *eap)
|
|||||||
goto ret_free;
|
goto ret_free;
|
||||||
|
|
||||||
erret:
|
erret:
|
||||||
ga_clear_strings(&newargs);
|
|
||||||
ga_clear_strings(&default_args);
|
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
|
// these were set to "newargs" and "default_args", which are cleared below
|
||||||
ga_init(&fp->uf_args, (int)sizeof(char *), 1);
|
ga_init(&fp->uf_args, (int)sizeof(char *), 1);
|
||||||
ga_init(&fp->uf_def_args, (int)sizeof(char *), 1);
|
ga_init(&fp->uf_def_args, (int)sizeof(char *), 1);
|
||||||
}
|
}
|
||||||
errret_2:
|
errret_2:
|
||||||
|
ga_clear_strings(&newargs);
|
||||||
|
ga_clear_strings(&default_args);
|
||||||
ga_clear_strings(&newlines);
|
ga_clear_strings(&newlines);
|
||||||
if (free_fp) {
|
if (free_fp) {
|
||||||
xfree(fp);
|
xfree(fp);
|
||||||
|
|||||||
Reference in New Issue
Block a user