aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c6
-rw-r--r--src/nvim/eval/executor.c8
-rw-r--r--src/nvim/eval/funcs.c13
3 files changed, 24 insertions, 3 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 176d75b04d..d1f9adf2d0 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -3678,6 +3678,10 @@ static int eval_method(char **const arg, typval_T *const rettv, evalarg_T *const
}
xfree(tofree);
+ if (alias != NULL) {
+ xfree(alias);
+ }
+
return ret;
}
@@ -3815,7 +3819,7 @@ static int check_can_index(typval_T *rettv, bool evaluate, bool verbose)
/// slice() function
void f_slice(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
- if (check_can_index(argvars, true, false) != OK) {
+ if (check_can_index(&argvars[0], true, false) != OK) {
return;
}
diff --git a/src/nvim/eval/executor.c b/src/nvim/eval/executor.c
index 26b7a627a6..5b92f217d1 100644
--- a/src/nvim/eval/executor.c
+++ b/src/nvim/eval/executor.c
@@ -31,7 +31,13 @@ static int tv_op_blob(typval_T *tv1, const typval_T *tv2, const char *op)
}
// Blob += Blob
- if (tv1->vval.v_blob == NULL || tv2->vval.v_blob == NULL) {
+ if (tv2->vval.v_blob == NULL) {
+ return OK;
+ }
+
+ if (tv1->vval.v_blob == NULL) {
+ tv1->vval.v_blob = tv2->vval.v_blob;
+ tv1->vval.v_blob->bv_refcount++;
return OK;
}
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 22e7f383a5..bd977523c6 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -3880,6 +3880,7 @@ static varnumber_T indexof_blob(blob_T *b, varnumber_T startidx, typval_T *expr)
}
}
+ const int called_emsg_start = called_emsg;
for (varnumber_T idx = startidx; idx < tv_blob_len(b); idx++) {
set_vim_var_nr(VV_KEY, idx);
set_vim_var_nr(VV_VAL, tv_blob_get(b, (int)idx));
@@ -3887,6 +3888,10 @@ static varnumber_T indexof_blob(blob_T *b, varnumber_T startidx, typval_T *expr)
if (indexof_eval_expr(expr)) {
return idx;
}
+
+ if (called_emsg != called_emsg_start) {
+ return -1;
+ }
}
return -1;
@@ -3916,6 +3921,7 @@ static varnumber_T indexof_list(list_T *l, varnumber_T startidx, typval_T *expr)
}
}
+ const int called_emsg_start = called_emsg;
for (; item != NULL; item = TV_LIST_ITEM_NEXT(l, item), idx++) {
set_vim_var_nr(VV_KEY, idx);
tv_copy(TV_LIST_ITEM_TV(item), get_vim_var_tv(VV_VAL));
@@ -3926,6 +3932,10 @@ static varnumber_T indexof_list(list_T *l, varnumber_T startidx, typval_T *expr)
if (found) {
return idx;
}
+
+ if (called_emsg != called_emsg_start) {
+ return -1;
+ }
}
return -1;
@@ -3942,7 +3952,8 @@ static void f_indexof(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
return;
}
- if ((argvars[1].v_type == VAR_STRING && argvars[1].vval.v_string == NULL)
+ if ((argvars[1].v_type == VAR_STRING
+ && (argvars[1].vval.v_string == NULL || *argvars[1].vval.v_string == NUL))
|| (argvars[1].v_type == VAR_FUNC && argvars[1].vval.v_partial == NULL)) {
return;
}