patch 8.2.4322: Vim9: crash when using funcref with closure
Problem: Vim9: crash when using funcref with closure.
Solution: Keep a reference to the funcref that has the outer context.
(closes #9716)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index eb12e75..b031369 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4456,7 +4456,10 @@
}
if (arg_pt != NULL)
- pt->pt_outer = arg_pt->pt_outer;
+ {
+ pt->pt_outer_partial = arg_pt;
+ ++arg_pt->pt_refcount;
+ }
}
rettv->v_type = VAR_PARTIAL;
rettv->vval.v_partial = pt;