patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Problem: Errors when calling prop_remove() for an unloaded buffer.
Solution: Bail out when the buffer is not loaded. Add a few more tests for
failing when the buffer number is invalid.
diff --git a/src/textprop.c b/src/textprop.c
index 9011c66..fcf3741 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -129,7 +129,7 @@
di = dict_find(arg->vval.v_dict, (char_u *)"bufnr", -1);
if (di != NULL)
{
- *buf = tv_get_buf(&di->di_tv, FALSE);
+ *buf = get_buf_arg(&di->di_tv);
if (*buf == NULL)
return FAIL;
}
@@ -560,13 +560,10 @@
}
dict = argvars[0].vval.v_dict;
- di = dict_find(dict, (char_u *)"bufnr", -1);
- if (di != NULL)
- {
- buf = tv_get_buf(&di->di_tv, FALSE);
- if (buf == NULL)
- return;
- }
+ if (get_bufnr_from_arg(&argvars[0], &buf) == FAIL)
+ return;
+ if (buf->b_ml.ml_mfp == NULL)
+ return;
di = dict_find(dict, (char_u*)"all", -1);
if (di != NULL)
@@ -628,7 +625,7 @@
buf->b_ml.ml_flags |= ML_LINE_DIRTY;
cur_prop = buf->b_ml.ml_line_ptr + len
- + idx * sizeof(textprop_T);
+ + idx * sizeof(textprop_T);
}
taillen = buf->b_ml.ml_line_len - len