0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -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:
Bram Moolenaar
2021-09-11 23:07:44 +02:00
parent 35a9a00afc
commit 464393a696
3 changed files with 19 additions and 3 deletions

View File

@@ -3462,9 +3462,21 @@ set_var_const(
if (vim9script && type != 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)
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