diff src/vim9compile.c @ 22381:6fe9536694ff v8.2.1739

patch 8.2.1739: Vim9: crash when compiling a manually defined function Commit: https://github.com/vim/vim/commit/9c4f55204fdf8909f4e3515a32a542044bf9f943 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 25 21:47:28 2020 +0200 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)
author Bram Moolenaar <Bram@vim.org>
date Fri, 25 Sep 2020 22:00:04 +0200
parents 15003353a464
children a9fb7efa31d6
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -277,9 +277,12 @@ script_is_vim9()
 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];