patch 8.2.1739: Vim9: crash when compiling a manually defined function
Problem: Vim9: crash when compiling a manually defined function. (Antony
Scriven)
Solution: Check that the script ID is positive. (closes #7012)
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 6ed166d..5d0ccb6 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -277,9 +277,12 @@
lookup_script(char_u *name, size_t len, int vim9script)
{
int cc;
- hashtab_T *ht = &SCRIPT_VARS(current_sctx.sc_sid);
+ hashtab_T *ht;
dictitem_T *di;
+ if (current_sctx.sc_sid <= 0)
+ return FAIL;
+ ht = &SCRIPT_VARS(current_sctx.sc_sid);
if (vim9script && !script_is_vim9())
return FAIL;
cc = name[len];