To: vim_dev@googlegroups.com Subject: Patch 9.0.1104 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1104 Problem: Invalid memory access when checking function argument types. Solution: Do not check beyond the number of arguments. (closes #11755) Files: src/vim9type.c, src/testdir/test_vim9_func.vim *** ../vim-9.0.1103/src/vim9type.c 2022-12-13 21:14:19.219930894 +0000 --- src/vim9type.c 2022-12-27 17:02:14.991264919 +0000 *************** *** 848,854 **** { int i; ! for (i = 0; i < expected->tt_argcount; ++i) // Allow for using "any" argument type, lambda's have them. if (actual->tt_args[i] != &t_any && check_type( expected->tt_args[i], actual->tt_args[i], FALSE, --- 848,854 ---- { int i; ! for (i = 0; i < expected->tt_argcount && i < actual->tt_argcount; ++i) // Allow for using "any" argument type, lambda's have them. if (actual->tt_args[i] != &t_any && check_type( expected->tt_args[i], actual->tt_args[i], FALSE, *** ../vim-9.0.1103/src/testdir/test_vim9_func.vim 2022-12-02 18:12:01.022476815 +0000 --- src/testdir/test_vim9_func.vim 2022-12-27 17:15:05.182570957 +0000 *************** *** 426,431 **** --- 426,441 ---- Func() END v9.CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected number but got bool', 2) + + lines =<< trim END + vim9script + + def Foobar(Fn: func(any, ?string): any) + enddef + + Foobar((t) => 0) + END + v9.CheckScriptSuccess(lines) enddef def Test_missing_return() *** ../vim-9.0.1103/src/version.c 2022-12-26 15:35:11.357868057 +0000 --- src/version.c 2022-12-27 17:09:39.214852769 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1104, /**/ -- ROBIN: The what? ARTHUR: The Holy Hand Grenade of Antioch. 'Tis one of the sacred relics Brother Maynard always carries with him. ALL: Yes. Of course. ARTHUR: (shouting) Bring up the Holy Hand Grenade! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///