To: vim_dev@googlegroups.com Subject: Patch 8.2.4782 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4782 Problem: Accessing freed memory. Solution: Clear evalarg after checking for trailing characters. (issue #10218) Files: src/userfunc.c, src/testdir/test_lambda.vim *** ../vim-8.2.4781/src/userfunc.c 2022-04-17 12:46:50.101294003 +0100 --- src/userfunc.c 2022-04-18 15:19:45.984931378 +0100 *************** *** 5529,5535 **** } if (eap->skip) --emsg_skip; - clear_evalarg(&evalarg, eap); // When inside :try we need to check for following "| catch" or "| endtry". // Not when there was an error, but do check if an exception was thrown. --- 5529,5534 ---- *************** *** 5549,5554 **** --- 5548,5555 ---- else set_nextcmd(eap, arg); } + // Must be after using "arg", it may point into memory cleared here. + clear_evalarg(&evalarg, eap); end: dict_unref(fudi.fd_dict); *** ../vim-8.2.4781/src/testdir/test_lambda.vim 2022-04-17 15:06:31.042622659 +0100 --- src/testdir/test_lambda.vim 2022-04-18 15:18:52.880952986 +0100 *************** *** 1,6 **** --- 1,7 ---- " Test for lambda and closure source check.vim + import './vim9.vim' as v9 func Test_lambda_feature() call assert_equal(1, has('lambda')) *************** *** 54,59 **** --- 55,75 ---- call assert_true(s:n > m) endfunc + func Test_lambda_vim9cmd_linebreak() + CheckFeature timers + + let lines =<< trim END + vim9cmd call timer_start(10, (x) => { + # comment + g:result = 'done' + }) + END + call v9.CheckScriptSuccess(lines) + sleep 50m + call assert_equal('done', g:result) + unlet g:result + endfunc + func Test_lambda_with_partial() let l:Cb = function({... -> ['zero', a:1, a:2, a:3]}, ['one', 'two']) call assert_equal(['zero', 'one', 'two', 'three'], l:Cb('three')) *** ../vim-8.2.4781/src/version.c 2022-04-18 14:32:39.658029923 +0100 --- src/version.c 2022-04-18 15:08:32.753261806 +0100 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4782, /**/ -- hundred-and-one symptoms of being an internet addict: 25. You believe nothing looks sexier than a man in boxer shorts illuminated only by a 17" inch svga monitor. /// 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 ///