mirror of
https://github.com/neovim/neovim.git
synced 2026-02-21 18:01:17 +10:00
vim-patch:9.1.2086: Memory leak when skipping invalid literal dict
Problem: memory leak when not evaluating (just parsing) invalid literal
dict.
Solution: Always clear the key's typval (Sean Dewar)
Though "check_typval_is_value(&tv) == FAIL && !evaluate" is maybe never
true, also always clear tvs if check_typval_is_value fails; at worst
this would be a no-op as their initial types are VAR_UNKNOWN.
closes: vim/vim#19178
b10a3e1a20
check_typval_is_value change is for Vim9 script. (from 9.0.2163)
N/A patch:
vim-patch:9.0.2163: Vim9: type can be assigned to list/dict
Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
(cherry picked from commit ba1d50fdc3)
This commit is contained in:
committed by
github-actions[bot]
parent
10a1df2789
commit
600d9f35a4
@@ -5233,9 +5233,7 @@ static int eval_dict(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool
|
|||||||
|
|
||||||
*arg = skipwhite(*arg + 1);
|
*arg = skipwhite(*arg + 1);
|
||||||
if (eval1(arg, &tv, evalarg) == FAIL) { // Recursive!
|
if (eval1(arg, &tv, evalarg) == FAIL) { // Recursive!
|
||||||
if (evaluate) {
|
tv_clear(&tvkey);
|
||||||
tv_clear(&tvkey);
|
|
||||||
}
|
|
||||||
goto failret;
|
goto failret;
|
||||||
}
|
}
|
||||||
if (evaluate) {
|
if (evaluate) {
|
||||||
|
|||||||
@@ -560,6 +560,8 @@ func Test_dict_literal_keys()
|
|||||||
" why *{} cannot be used for a literal dictionary
|
" why *{} cannot be used for a literal dictionary
|
||||||
let blue = 'blue'
|
let blue = 'blue'
|
||||||
call assert_equal('6', trim(execute('echo 2 *{blue: 3}.blue')))
|
call assert_equal('6', trim(execute('echo 2 *{blue: 3}.blue')))
|
||||||
|
|
||||||
|
call assert_fails('eval 1 || #{a:', 'E15:') " used to leak
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Nasty: deepcopy() dict that refers to itself (fails when noref used)
|
" Nasty: deepcopy() dict that refers to itself (fails when noref used)
|
||||||
|
|||||||
Reference in New Issue
Block a user