• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisão41e118669df33a084f8f0ce470727eebab1b6cb9 (tree)
Hora2020-09-19 04:30:04
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Mensagem de Log

patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error

Commit: https://github.com/vim/vim/commit/7cbfaa51de7b225effdc79a008c71a5551883c38
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Sep 18 21:25:32 2020 +0200

patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Problem: Vim9: crash after running into the "Multiple closures" error.
Solution: When a function fails still update any closures. (closes https://github.com/vim/vim/issues/6973)

Mudança Sumário

Diff

diff -r 9b684e0b4c2f -r 41e118669df3 src/testdir/test_vim9_func.vim
--- a/src/testdir/test_vim9_func.vim Fri Sep 18 19:45:05 2020 +0200
+++ b/src/testdir/test_vim9_func.vim Fri Sep 18 21:30:04 2020 +0200
@@ -1294,6 +1294,20 @@
12941294 GetResult(g:Ref)->assert_equal('sometext')
12951295 enddef
12961296
1297+def Test_double_closure_fails()
1298+ let lines =<< trim END
1299+ vim9script
1300+ def Func()
1301+ let var = 0
1302+ for i in range(2)
1303+ timer_start(0, {-> var})
1304+ endfor
1305+ enddef
1306+ Func()
1307+ END
1308+ CheckScriptFailure(lines, 'Multiple closures not supported yet')
1309+enddef
1310+
12971311 def Test_sort_return_type()
12981312 let res: list<number>
12991313 res = [1, 2, 3]->sort()
diff -r 9b684e0b4c2f -r 41e118669df3 src/version.c
--- a/src/version.c Fri Sep 18 19:45:05 2020 +0200
+++ b/src/version.c Fri Sep 18 21:30:04 2020 +0200
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 1706,
755+/**/
754756 1705,
755757 /**/
756758 1704,
diff -r 9b684e0b4c2f -r 41e118669df3 src/vim9execute.c
--- a/src/vim9execute.c Fri Sep 18 19:45:05 2020 +0200
+++ b/src/vim9execute.c Fri Sep 18 21:30:04 2020 +0200
@@ -2676,15 +2676,11 @@
26762676 continue;
26772677
26782678 func_return:
2679- // Restore previous function. If the frame pointer is zero then there
2680- // is none and we are done.
2679+ // Restore previous function. If the frame pointer is where we started
2680+ // then there is none and we are done.
26812681 if (ectx.ec_frame_idx == initial_frame_idx)
2682- {
2683- if (handle_closure_in_use(&ectx, FALSE) == FAIL)
2684- // only fails when out of memory
2685- goto failed;
26862682 goto done;
2687- }
2683+
26882684 if (func_return(&ectx) == FAIL)
26892685 // only fails when out of memory
26902686 goto failed;
@@ -2703,6 +2699,10 @@
27032699 ret = OK;
27042700
27052701 failed:
2702+ // Also deal with closures when failed, they may already be in use
2703+ // somewhere.
2704+ handle_closure_in_use(&ectx, FALSE);
2705+
27062706 // When failed need to unwind the call stack.
27072707 while (ectx.ec_frame_idx != initial_frame_idx)
27082708 func_return(&ectx);
Show on old repository browser