diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-05-24 21:22:29 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-05-24 21:22:29 +0200 |
commit | f0884c5f3f5a25481d1e16f0979aa978a6690bb1 (patch) | |
tree | 4cc8521c7b5093a3218fed032d02e6fba8bf71e9 /src/textprop.c | |
parent | d79eef2eb1f24b53206c4e55b80a4634f548c429 (diff) | |
download | vim-git-f0884c5f3f5a25481d1e16f0979aa978a6690bb1.tar.gz |
patch 8.1.1388: errors when calling prop_remove() for an unloaded bufferv8.1.1388
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.
Diffstat (limited to 'src/textprop.c')
-rw-r--r-- | src/textprop.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/textprop.c b/src/textprop.c index 9011c663e..fcf374140 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -129,7 +129,7 @@ get_bufnr_from_arg(typval_T *arg, buf_T **buf) 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 @@ f_prop_remove(typval_T *argvars, typval_T *rettv) } 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 @@ f_prop_remove(typval_T *argvars, typval_T *rettv) 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 |