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

patch 8.2.2549: crash after using "g:" in a for loop

Problem:    Crash after using "g:" in a for loop.
Solution:   Increment the reference count. (closes #7892)
This commit is contained in:
Bram Moolenaar
2021-02-24 12:27:31 +01:00
parent 7d41410a45
commit 1bd3cb2019
3 changed files with 9 additions and 0 deletions

View File

@@ -2545,6 +2545,12 @@ def Test_expr7_namespace()
assert_equal('some', get(t:, 'some_var', 'xxx')) assert_equal('some', get(t:, 'some_var', 'xxx'))
assert_equal('xxx', get(t:, 'no_var', 'xxx')) assert_equal('xxx', get(t:, 'no_var', 'xxx'))
unlet t:some_var unlet t:some_var
# check using g: in a for loop more than DO_NOT_FREE_CNT times
for i in range(100000)
if has_key(g:, 'does-not-exist')
endif
endfor
enddef enddef
def Test_expr7_parens() def Test_expr7_parens()

View File

@@ -750,6 +750,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 */
/**/
2549,
/**/ /**/
2548, 2548,
/**/ /**/

View File

@@ -1771,6 +1771,7 @@ call_def_function(
tv->v_type = VAR_DICT; tv->v_type = VAR_DICT;
tv->v_lock = 0; tv->v_lock = 0;
tv->vval.v_dict = d; tv->vval.v_dict = d;
++d->dv_refcount;
++ectx.ec_stack.ga_len; ++ectx.ec_stack.ga_len;
} }
break; break;