Patch 8.2.1945
Problem: Crash when passing NULL function to reduce().
Solution: Check for NULL pointer and give an error. (Dominique Pellé,
closes #7243)
Files: src/list.c, src/errors.h, src/testdir/test_listdict.vim
*** ../vim-8.2.1944/src/list.c 2020-11-01 13:57:37.551988657 +0100
--- src/list.c 2020-11-03 18:16:51.803007562 +0100
***************
*** 2552,2559 ****
}
else
func_name = tv_get_string(&argvars[1]);
! if (*func_name == NUL)
! return; // type error or empty name
vim_memset(&funcexe, 0, sizeof(funcexe));
funcexe.evaluate = TRUE;
--- 2552,2562 ----
}
else
func_name = tv_get_string(&argvars[1]);
! if (func_name == NULL || *func_name == NUL)
! {
! emsg(_(e_missing_function_argument));
! return;
! }
vim_memset(&funcexe, 0, sizeof(funcexe));
funcexe.evaluate = TRUE;
*** ../vim-8.2.1944/src/errors.h 2020-10-28 17:55:26.440231132 +0100
--- src/errors.h 2020-11-03 18:15:36.175212429 +0100
***************
*** 286,289 ****
--- 286,291 ----
INIT(= N_("E1130: Cannot add to null list"));
EXTERN char e_cannot_add_to_null_blob[]
INIT(= N_("E1131: Cannot add to null blob"));
+ EXTERN char e_missing_function_argument[]
+ INIT(= N_("E1132: Missing function argument"));
#endif
*** ../vim-8.2.1944/src/testdir/test_listdict.vim 2020-10-30 19:04:39.049202455 +0100
--- src/testdir/test_listdict.vim 2020-11-03 18:19:05.730644914 +0100
***************
*** 740,745 ****
--- 740,748 ----
call assert_equal(42, reduce(test_null_list(), function('add'), 42))
call assert_equal(42, reduce(test_null_blob(), function('add'), 42))
+
+ " should not crash
+ call assert_fails('echo reduce([1], test_null_function())', 'E1132:')
endfunc
" splitting a string to a List using split()
*** ../vim-8.2.1944/src/version.c 2020-11-03 11:53:26.227750386 +0100
--- src/version.c 2020-11-03 18:11:25.227892245 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1945,
/**/
--
hundred-and-one symptoms of being an internet addict:
185. You order fast food over the Internet
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///