diff options
author | Bram Moolenaar <Bram@vim.org> | 2023-02-27 22:06:51 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-02-27 22:06:51 +0000 |
commit | 3f45d67a150f934ab819c3739cf189a0e2c9545c (patch) | |
tree | 6a221a2ff0bf1f90f48d7592b401a8217a95df5b | |
parent | 99ad3a8bb95c6f860545a050472b6181e33bac1a (diff) | |
download | vim-git-3f45d67a150f934ab819c3739cf189a0e2c9545c.tar.gz |
patch 9.0.1363: crash when :def function has :break in skipped blockv9.0.1363
Problem: Crash when :def function has :break in skipped block. (Ernie Rael)
Solution: Don't generate a jump for a skipped :break. (closes #12077)
-rw-r--r-- | src/testdir/test_vim9_func.vim | 25 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9cmds.c | 5 |
3 files changed, 31 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index f9ff3bc3e..0f28ba038 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -166,6 +166,31 @@ def Test_wrong_function_name() delfunc g:Define enddef +def Test_break_in_skipped_block() + var lines =<< trim END + vim9script + + def FixStackFrame(): string + for _ in [2] + var path = 'xxx' + if !!path + if false + break + else + return 'foo' + endif + endif + endfor + return 'xxx' + enddef + + disas FixStackFrame + + FixStackFrame() + END + v9.CheckScriptSuccess(lines) +enddef + def Test_autoload_name_mismatch() var dir = 'Xnamedir/autoload' mkdir(dir, 'pR') diff --git a/src/version.c b/src/version.c index b694119a5..aa9f88424 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1363, +/**/ 1362, /**/ 1361, diff --git a/src/vim9cmds.c b/src/vim9cmds.c index fb09780cb..bc01cd83d 100644 --- a/src/vim9cmds.c +++ b/src/vim9cmds.c @@ -1440,6 +1440,9 @@ compile_break(char_u *arg, cctx_T *cctx) e_break_without_while_or_for, cctx) == FAIL) return NULL; + if (cctx->ctx_skip == SKIP_YES) + return arg; + if (try_scopes > 0) // Inside one or more try/catch blocks we first need to jump to the // "finally" or "endtry" to cleanup. Then come to the next JUMP @@ -1449,7 +1452,7 @@ compile_break(char_u *arg, cctx_T *cctx) // Jump to the end of the FOR or WHILE loop. The instruction index will be // filled in later. if (compile_jump_to_end(el, JUMP_ALWAYS, 0, cctx) == FAIL) - return FAIL; + return NULL; return arg; } |