mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.3429: leaking memory when assigning to list or dict
Problem: Leaking memory when assigning to list or dict. Solution: Free the list or dict type before overwriting it.
This commit is contained in:
@@ -3462,9 +3462,21 @@ set_var_const(
|
|||||||
if (vim9script && type != NULL)
|
if (vim9script && type != NULL)
|
||||||
{
|
{
|
||||||
if (type->tt_type == VAR_DICT && dest_tv->vval.v_dict != NULL)
|
if (type->tt_type == VAR_DICT && dest_tv->vval.v_dict != NULL)
|
||||||
dest_tv->vval.v_dict->dv_type = alloc_type(type);
|
{
|
||||||
|
if (dest_tv->vval.v_dict->dv_type != type)
|
||||||
|
{
|
||||||
|
free_type(dest_tv->vval.v_dict->dv_type);
|
||||||
|
dest_tv->vval.v_dict->dv_type = alloc_type(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (type->tt_type == VAR_LIST && dest_tv->vval.v_list != NULL)
|
else if (type->tt_type == VAR_LIST && dest_tv->vval.v_list != NULL)
|
||||||
dest_tv->vval.v_list->lv_type = alloc_type(type);
|
{
|
||||||
|
if (dest_tv->vval.v_list->lv_type != type)
|
||||||
|
{
|
||||||
|
free_type(dest_tv->vval.v_list->lv_type);
|
||||||
|
dest_tv->vval.v_list->lv_type = alloc_type(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ":const var = value" locks the value
|
// ":const var = value" locks the value
|
||||||
|
@@ -755,6 +755,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 */
|
||||||
|
/**/
|
||||||
|
3429,
|
||||||
/**/
|
/**/
|
||||||
3428,
|
3428,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -258,7 +258,7 @@ func_type_add_arg_types(
|
|||||||
typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int do_member)
|
typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int do_member)
|
||||||
{
|
{
|
||||||
type_T *type;
|
type_T *type;
|
||||||
type_T *member_type = &t_any;
|
type_T *member_type = NULL;
|
||||||
int argcount = 0;
|
int argcount = 0;
|
||||||
int min_argcount = 0;
|
int min_argcount = 0;
|
||||||
|
|
||||||
@@ -268,6 +268,8 @@ typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int do_member)
|
|||||||
return &t_bool;
|
return &t_bool;
|
||||||
if (tv->v_type == VAR_STRING)
|
if (tv->v_type == VAR_STRING)
|
||||||
return &t_string;
|
return &t_string;
|
||||||
|
if (tv->v_type == VAR_BLOB)
|
||||||
|
return &t_blob;
|
||||||
|
|
||||||
if (tv->v_type == VAR_LIST)
|
if (tv->v_type == VAR_LIST)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user