patch 8.1.1575: callbacks may be garbage collected
Problem: Callbacks may be garbage collected.
Solution: Set reference in callbacks. (Ozaki Kiichi, closes #4564)
diff --git a/src/userfunc.c b/src/userfunc.c
index 197e2e0..8d1df0c 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -4032,12 +4032,12 @@
funccall_T *fc;
funccal_entry_T *entry;
- for (fc = current_funccal; fc != NULL; fc = fc->caller)
+ for (fc = current_funccal; !abort && fc != NULL; fc = fc->caller)
abort = abort || set_ref_in_funccal(fc, copyID);
// Also go through the funccal_stack.
- for (entry = funccal_stack; entry != NULL; entry = entry->next)
- for (fc = entry->top_funccal; fc != NULL; fc = fc->caller)
+ for (entry = funccal_stack; !abort && entry != NULL; entry = entry->next)
+ for (fc = entry->top_funccal; !abort && fc != NULL; fc = fc->caller)
abort = abort || set_ref_in_funccal(fc, copyID);
return abort;