Skip to content

Commit 1bd3cb2

Browse files
committed
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)
1 parent 7d41410 commit 1bd3cb2

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/testdir/test_vim9_expr.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,6 +2545,12 @@ def Test_expr7_namespace()
25452545
assert_equal('some', get(t:, 'some_var', 'xxx'))
25462546
assert_equal('xxx', get(t:, 'no_var', 'xxx'))
25472547
unlet t:some_var
2548+
2549+
# check using g: in a for loop more than DO_NOT_FREE_CNT times
2550+
for i in range(100000)
2551+
if has_key(g:, 'does-not-exist')
2552+
endif
2553+
endfor
25482554
enddef
25492555

25502556
def Test_expr7_parens()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2549,
753755
/**/
754756
2548,
755757
/**/

src/vim9execute.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,6 +1771,7 @@ call_def_function(
17711771
tv->v_type = VAR_DICT;
17721772
tv->v_lock = 0;
17731773
tv->vval.v_dict = d;
1774+
++d->dv_refcount;
17741775
++ectx.ec_stack.ga_len;
17751776
}
17761777
break;

0 commit comments

Comments
 (0)