patch 7.4.1768
Problem: Arguments of setqflist() are not checked properly.
Solution: Add better checks, add a test. (Nikolai Pavlov, Hirohito Higashi,
closes #661)
diff --git a/src/eval.c b/src/eval.c
index 1daf042..b82a98f 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -98,6 +98,7 @@
static char *e_listdictarg = N_("E712: Argument of %s must be a List or Dictionary");
static char *e_listreq = N_("E714: List required");
static char *e_dictreq = N_("E715: Dictionary required");
+static char *e_stringreq = N_("E928: String required");
static char *e_toomanyarg = N_("E118: Too many arguments for function: %s");
static char *e_dictkey = N_("E716: Key not present in Dictionary: %s");
static char *e_funcexts = N_("E122: Function %s already exists, add ! to replace it");
@@ -18280,8 +18281,9 @@
typval_T *rettv)
{
#ifdef FEAT_QUICKFIX
+ static char *e_invact = N_("E927: Invalid action: '%s'");
char_u *act;
- int action = ' ';
+ int action = 0;
#endif
rettv->vval.v_number = -1;
@@ -18298,11 +18300,17 @@
act = get_tv_string_chk(action_arg);
if (act == NULL)
return; /* type error; errmsg already given */
- if (*act == 'a' || *act == 'r')
+ if ((*act == 'a' || *act == 'r' || *act == ' ') && act[1] == NUL)
action = *act;
+ else
+ EMSG2(_(e_invact), act);
}
+ else if (action_arg->v_type == VAR_UNKNOWN)
+ action = ' ';
+ else
+ EMSG(_(e_stringreq));
- if (l != NULL && set_errorlist(wp, l, action,
+ if (l != NULL && action && set_errorlist(wp, l, action,
(char_u *)(wp == NULL ? "setqflist()" : "setloclist()")) == OK)
rettv->vval.v_number = 0;
}