diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2021-07-29 22:47:33 +0100 |
---|---|---|
committer | Sean Dewar <seandewar@users.noreply.github.com> | 2021-09-16 00:14:46 +0100 |
commit | 3d6bb8b3fbe21d8a7a4ba975682eb9a4e5170859 (patch) | |
tree | f6ebc193e419d1320fbe88d11989fc2630d60343 | |
parent | ecb54238e00f66f46070a0a2d859531258377272 (diff) | |
download | rneovim-3d6bb8b3fbe21d8a7a4ba975682eb9a4e5170859.tar.gz rneovim-3d6bb8b3fbe21d8a7a4ba975682eb9a4e5170859.tar.bz2 rneovim-3d6bb8b3fbe21d8a7a4ba975682eb9a4e5170859.zip |
fix(f_remove): partially port v8.2.2779
Fixes remove() copying one extra byte after the end of a Blob's buffer.
Can't be fully ported as the change is from blob_remove(), which hasn't
been ported yet.
-rw-r--r-- | src/nvim/eval/funcs.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index b3afa332f8..660c069e7f 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -7334,7 +7334,7 @@ static void f_remove(typval_T *argvars, typval_T *rettv, FunPtr fptr) memmove(p + idx, p + idx + 1, (size_t)len - idx - 1); b->bv_ga.ga_len--; } else { - // Remove range of items, return list with values. + // Remove range of items, return blob with values. end = (long)tv_get_number_chk(&argvars[2], &error); if (error) { return; @@ -7356,7 +7356,9 @@ static void f_remove(typval_T *argvars, typval_T *rettv, FunPtr fptr) (size_t)(end - idx + 1)); tv_blob_set_ret(rettv, blob); - memmove(p + idx, p + end + 1, (size_t)(len - end)); + if (len - end - 1 > 0) { + memmove(p + idx, p + end + 1, (size_t)(len - end - 1)); + } b->bv_ga.ga_len -= end - idx + 1; } } |