mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 02:46:31 +00:00
vim-patch:9.0.1492: using uninitialized memory when argument is missing (#23351)
Problem: Using uninitialized memory when argument is missing.
Solution: Check there are sufficient arguments before the base.
(closes vim/vim#12302)
b7f2270bab
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -287,6 +287,9 @@ int call_internal_method(const char *const fname, const int argcount, typval_T *
|
|||||||
|
|
||||||
typval_T argv[MAX_FUNC_ARGS + 1];
|
typval_T argv[MAX_FUNC_ARGS + 1];
|
||||||
const ptrdiff_t base_index = fdef->base_arg == BASE_LAST ? argcount : fdef->base_arg - 1;
|
const ptrdiff_t base_index = fdef->base_arg == BASE_LAST ? argcount : fdef->base_arg - 1;
|
||||||
|
if (argcount < base_index) {
|
||||||
|
return FCERR_TOOFEW;
|
||||||
|
}
|
||||||
memcpy(argv, argvars, (size_t)base_index * sizeof(typval_T));
|
memcpy(argv, argvars, (size_t)base_index * sizeof(typval_T));
|
||||||
argv[base_index] = *basetv;
|
argv[base_index] = *basetv;
|
||||||
memcpy(argv + base_index + 1, argvars + base_index,
|
memcpy(argv + base_index + 1, argvars + base_index,
|
||||||
|
@@ -407,6 +407,9 @@ func Test_printf_misc()
|
|||||||
call CheckLegacyAndVim9Success(lines)
|
call CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call CheckLegacyAndVim9Failure(["call printf('123', 3)"], "E767:")
|
call CheckLegacyAndVim9Failure(["call printf('123', 3)"], "E767:")
|
||||||
|
|
||||||
|
" this was using uninitialized memory
|
||||||
|
call CheckLegacyAndVim9Failure(["eval ''->printf()"], "E119:")
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_printf_float()
|
func Test_printf_float()
|
||||||
|
Reference in New Issue
Block a user