summaryrefslogtreecommitdiff
path: root/src/vim9script.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-16 23:18:51 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-16 23:18:51 +0200
commit101f4810e27e432970bc8809e18f018e1795937f (patch)
treee9087cbb9b5d767866fce51696cce626fc21d051 /src/vim9script.c
parent0fe937fd8616fcd24b1b1ef2ab9f1657615dd22c (diff)
downloadvim-git-101f4810e27e432970bc8809e18f018e1795937f.tar.gz
patch 8.2.0992: Vim9: crash when using :import in the Vim commandv8.2.0992
Problem: Vim9: crash when using :import in the Vim command. Solution: Give an error when using :import outside of a script. (closes #6271)
Diffstat (limited to 'src/vim9script.c')
-rw-r--r--src/vim9script.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/vim9script.c b/src/vim9script.c
index cdbcb47e7..442158c48 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -32,13 +32,14 @@ in_vim9script(void)
void
ex_vim9script(exarg_T *eap)
{
- scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
+ scriptitem_T *si;
if (!getline_equal(eap->getline, eap->cookie, getsourceline))
{
emsg(_("E1038: vim9script can only be used in a script"));
return;
}
+ si = SCRIPT_ITEM(current_sctx.sc_sid);
if (si->sn_had_command)
{
emsg(_("E1039: vim9script must be the first command in a script"));
@@ -141,8 +142,15 @@ free_imports(int sid)
void
ex_import(exarg_T *eap)
{
- char_u *cmd_end = handle_import(eap->arg, NULL, current_sctx.sc_sid, NULL);
+ char_u *cmd_end;
+
+ if (!getline_equal(eap->getline, eap->cookie, getsourceline))
+ {
+ emsg(_("E1094: import can only be used in a script"));
+ return;
+ }
+ cmd_end = handle_import(eap->arg, NULL, current_sctx.sc_sid, NULL);
if (cmd_end != NULL)
eap->nextcmd = check_nextcmd(cmd_end);
}