patch 8.2.1154: Vim9: crash when using imported function
Problem: Vim9: crash when using imported function.
Solution: Check for a function type. Set the script context when calling a
function. (closes #6412)
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 9ffc66c..ce4bafa 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -68,7 +68,7 @@
/*
* Add a user function to the execution stack.
*/
- void
+ estack_T *
estack_push_ufunc(ufunc_T *ufunc, long lnum)
{
estack_T *entry = estack_push(ETYPE_UFUNC,
@@ -76,6 +76,7 @@
? ufunc->uf_name_exp : ufunc->uf_name, lnum);
if (entry != NULL)
entry->es_info.ufunc = ufunc;
+ return entry;
}
/*
@@ -97,13 +98,15 @@
#endif
/*
- * Take an item off of the execution stack.
+ * Take an item off of the execution stack and return it.
*/
- void
+ estack_T *
estack_pop(void)
{
- if (exestack.ga_len > 1)
- --exestack.ga_len;
+ if (exestack.ga_len == 0)
+ return NULL;
+ --exestack.ga_len;
+ return ((estack_T *)exestack.ga_data) + exestack.ga_len;
}
/*