diff src/vim9compile.c @ 23576:4cd173b3d572 v8.2.2330

patch 8.2.2330: Vim9: crash when using :trow in a not executed block Commit: https://github.com/vim/vim/commit/9e1d9e3473f852735ffd605a0fa4d224b81a4f0c Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 11 20:17:34 2021 +0100 patch 8.2.2330: Vim9: crash when using :trow in a not executed block Problem: Vim9: crash when using :trow in a not executed block. Solution: Don't generate the instruction when skipping. (closes https://github.com/vim/vim/issues/7659)
author Bram Moolenaar <Bram@vim.org>
date Mon, 11 Jan 2021 20:30:04 +0100
parents 34aa2907082a
children 85ce241ff9e3
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -474,8 +474,10 @@ may_generate_2STRING(int offset, cctx_T 
     isn_T	*isn;
     isntype_T	isntype = ISN_2STRING;
     garray_T	*stack = &cctx->ctx_type_stack;
-    type_T	**type = ((type_T **)stack->ga_data) + stack->ga_len + offset;
-
+    type_T	**type;
+
+    RETURN_OK_IF_SKIP(cctx);
+    type = ((type_T **)stack->ga_data) + stack->ga_len + offset;
     switch ((*type)->tt_type)
     {
 	// nothing to be done
@@ -7461,6 +7463,8 @@ compile_throw(char_u *arg, cctx_T *cctx 
 
     if (compile_expr0(&p, cctx) == FAIL)
 	return NULL;
+    if (cctx->ctx_skip == SKIP_YES)
+	return p;
     if (may_generate_2STRING(-1, cctx) == FAIL)
 	return NULL;
     if (generate_instr_drop(cctx, ISN_THROW, 1) == NULL)