0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.1134: Vim9: getting a list member may not work

Problem:    Vim9: getting a list member may not work.
Solution:   Clear the list only after copying the item. (closes #6393)
This commit is contained in:
Bram Moolenaar
2020-07-05 16:42:13 +02:00
parent fce82b3aa7
commit 435d89789e
3 changed files with 14 additions and 2 deletions

View File

@@ -2085,6 +2085,7 @@ call_def_function(
list_T *list;
varnumber_T n;
listitem_T *li;
typval_T temp_tv;
// list index: list is at stack-2, index at stack-1
tv = STACK_TV_BOT(-2);
@@ -2109,8 +2110,12 @@ call_def_function(
goto failed;
}
--ectx.ec_stack.ga_len;
clear_tv(STACK_TV_BOT(-1));
copy_tv(&li->li_tv, STACK_TV_BOT(-1));
// Clear the list after getting the item, to avoid that it
// make the item invalid.
tv = STACK_TV_BOT(-1);
temp_tv = *tv;
copy_tv(&li->li_tv, tv);
clear_tv(&temp_tv);
}
break;