mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.1945: crash when passing NULL function to reduce()
Problem: Crash when passing NULL function to reduce(). Solution: Check for NULL pointer and give an error. (Dominique Pellé, closes #7243)
This commit is contained in:
parent
6fd3a4ba23
commit
0d90e728fe
@ -286,4 +286,6 @@ EXTERN char e_cannot_add_to_null_list[]
|
|||||||
INIT(= N_("E1130: Cannot add to null list"));
|
INIT(= N_("E1130: Cannot add to null list"));
|
||||||
EXTERN char e_cannot_add_to_null_blob[]
|
EXTERN char e_cannot_add_to_null_blob[]
|
||||||
INIT(= N_("E1131: 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
|
#endif
|
||||||
|
@ -2552,8 +2552,11 @@ f_reduce(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
func_name = tv_get_string(&argvars[1]);
|
func_name = tv_get_string(&argvars[1]);
|
||||||
if (*func_name == NUL)
|
if (func_name == NULL || *func_name == NUL)
|
||||||
return; // type error or empty name
|
{
|
||||||
|
emsg(_(e_missing_function_argument));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
vim_memset(&funcexe, 0, sizeof(funcexe));
|
vim_memset(&funcexe, 0, sizeof(funcexe));
|
||||||
funcexe.evaluate = TRUE;
|
funcexe.evaluate = TRUE;
|
||||||
|
@ -740,6 +740,9 @@ func Test_reduce()
|
|||||||
|
|
||||||
call assert_equal(42, reduce(test_null_list(), function('add'), 42))
|
call assert_equal(42, reduce(test_null_list(), function('add'), 42))
|
||||||
call assert_equal(42, reduce(test_null_blob(), 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
|
endfunc
|
||||||
|
|
||||||
" splitting a string to a List using split()
|
" splitting a string to a List using split()
|
||||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1945,
|
||||||
/**/
|
/**/
|
||||||
1944,
|
1944,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user