patch 8.1.1485: double free when garbage_collect() is used in autocommand
Problem: Double free when garbage_collect() is used in autocommand.
Solution: Have garbage collection also set the copyID in funccal_stack.
diff --git a/src/eval.c b/src/eval.c
index 5452f45..abb3b40 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -430,12 +430,11 @@
vim_free(SCRIPT_SV(i));
ga_clear(&ga_scripts);
- // functions need to be freed before gargabe collecting, otherwise local
- // variables might be freed twice.
- free_all_functions();
-
// unreferenced lists and dicts
(void)garbage_collect(FALSE);
+
+ // functions not garbage collected
+ free_all_functions();
}
#endif