summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/eval.c b/src/eval.c
index dac086f856..f111dc4312 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -4723,12 +4723,13 @@ eval_index(
}
else
{
- // The resulting variable is a string of a single
- // character. If the index is too big or negative the
- // result is empty.
+ // The resulting variable is a byte value.
+ // If the index is too big or negative that is an error.
+ if (n1 < 0)
+ n1 = len + n1;
if (n1 < len && n1 >= 0)
{
- int v = (int)blob_get(rettv->vval.v_blob, n1);
+ int v = blob_get(rettv->vval.v_blob, n1);
clear_tv(rettv);
rettv->v_type = VAR_NUMBER;