mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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 #11774)
This commit is contained in:
@@ -525,9 +525,9 @@ parse_argument_types(ufunc_T *fp, garray_T *argtypes, int varargs)
|
|||||||
|
|
||||||
// Move the last argument "...name: type" to uf_va_name and
|
// Move the last argument "...name: type" to uf_va_name and
|
||||||
// uf_va_type.
|
// uf_va_type.
|
||||||
fp->uf_va_name = ((char_u **)fp->uf_args.ga_data)
|
|
||||||
[fp->uf_args.ga_len - 1];
|
|
||||||
--fp->uf_args.ga_len;
|
--fp->uf_args.ga_len;
|
||||||
|
fp->uf_va_name = ((char_u **)fp->uf_args.ga_data)[fp->uf_args.ga_len];
|
||||||
|
((char_u **)fp->uf_args.ga_data)[fp->uf_args.ga_len] = NULL;
|
||||||
p = ((char_u **)argtypes->ga_data)[len];
|
p = ((char_u **)argtypes->ga_data)[len];
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
// TODO: get type from default value
|
// TODO: get type from default value
|
||||||
@@ -5209,17 +5209,23 @@ define_function(
|
|||||||
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);
|
ga_init(&fp->uf_args);
|
||||||
ga_init(&fp->uf_def_args);
|
ga_init(&fp->uf_def_args);
|
||||||
}
|
}
|
||||||
errret_2:
|
errret_2:
|
||||||
|
ga_clear_strings(&newargs);
|
||||||
|
ga_clear_strings(&default_args);
|
||||||
ga_clear_strings(&newlines);
|
ga_clear_strings(&newlines);
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
|
{
|
||||||
VIM_CLEAR(fp->uf_arg_types);
|
VIM_CLEAR(fp->uf_arg_types);
|
||||||
|
VIM_CLEAR(fp->uf_va_name);
|
||||||
|
clear_type_list(&fp->uf_type_list);
|
||||||
|
}
|
||||||
if (free_fp)
|
if (free_fp)
|
||||||
{
|
{
|
||||||
vim_free(fp);
|
vim_free(fp);
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1142,
|
||||||
/**/
|
/**/
|
||||||
1141,
|
1141,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user