summaryrefslogtreecommitdiff
path: root/src/blob.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-24 12:31:44 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-24 12:31:44 +0100
commita5be9b62480a6f338a72c01e57c9edd0bca8048b (patch)
tree175b99b7f3066c78c025858a4278c4359854a3f7 /src/blob.c
parentfb1199d934a27d338b18fe914e328346f093d3f6 (diff)
downloadvim-git-a5be9b62480a6f338a72c01e57c9edd0bca8048b.tar.gz
patch 8.1.0802: negative index doesn't work for Blobv8.1.0802
Problem: Negative index doesn't work for Blob. Solution: Make it work, add a test. (closes #3856)
Diffstat (limited to 'src/blob.c')
-rw-r--r--src/blob.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/blob.c b/src/blob.c
index a95403033..9dc7926f4 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -72,8 +72,12 @@ blob_copy(typval_T *from, typval_T *to)
int len = from->vval.v_blob->bv_ga.ga_len;
if (len > 0)
+ {
to->vval.v_blob->bv_ga.ga_data =
vim_memsave(from->vval.v_blob->bv_ga.ga_data, len);
+ if (to->vval.v_blob->bv_ga.ga_data == NULL)
+ len = 0;
+ }
to->vval.v_blob->bv_ga.ga_len = len;
}
return ret;
@@ -112,7 +116,7 @@ blob_len(blob_T *b)
* Get byte "idx" in blob "b".
* Caller must check that "idx" is valid.
*/
- char_u
+ int
blob_get(blob_T *b, int idx)
{
return ((char_u*)b->bv_ga.ga_data)[idx];