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.
This commit is contained in:
Sean Dewar 2021-07-29 22:47:33 +01:00
parent ecb54238e0
commit 3d6bb8b3fb
No known key found for this signature in database
GPG Key ID: 08CC2C83AD41B581

View File

@ -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;
}
}