patch 8.1.2282: crash when passing many arguments through a partial
Problem: Crash when passing many arguments through a partial. (Andy
Massimino)
Solution: Check the number of arguments. (closes #5186)
diff --git a/src/userfunc.c b/src/userfunc.c
index cfc52be..6fa5854 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -408,7 +408,7 @@
* Give an error message with a function name. Handle <SNR> things.
* "ermsg" is to be passed without translation, use N_() instead of _().
*/
- static void
+ void
emsg_funcname(char *ermsg, char_u *name)
{
char_u *p;
@@ -1537,7 +1537,14 @@
if (error == ERROR_NONE && partial->pt_argc > 0)
{
for (argv_clear = 0; argv_clear < partial->pt_argc; ++argv_clear)
+ {
+ if (argv_clear + argcount_in >= MAX_FUNC_ARGS)
+ {
+ error = ERROR_TOOMANY;
+ goto theend;
+ }
copy_tv(&partial->pt_argv[argv_clear], &argv[argv_clear]);
+ }
for (i = 0; i < argcount_in; ++i)
argv[i + argv_clear] = argvars_in[i];
argvars = argv;
@@ -1672,6 +1679,7 @@
if (error == ERROR_NONE)
ret = OK;
+theend:
/*
* Report an error unless the argument evaluation or function call has been
* cancelled due to an aborting error, an interrupt, or an exception.