summaryrefslogtreecommitdiffhomepage
path: root/types.c
diff options
context:
space:
mode:
Diffstat (limited to 'types.c')
-rw-r--r--types.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/types.c b/types.c
index 82c93cb..06f1957 100644
--- a/types.c
+++ b/types.c
@@ -1980,6 +1980,9 @@ ucv_key_get(uc_vm_t *vm, uc_value_t *scope, uc_value_t *key)
if (ucv_type(scope) == UC_ARRAY) {
idx = ucv_key_to_index(key);
+ if (idx < 0 && idx >= -INT64_MAX && llabs(idx) <= ucv_array_length(scope))
+ idx += ucv_array_length(scope);
+
if (idx >= 0 && (uint64_t)idx < ucv_array_length(scope))
return ucv_get(ucv_array_get(scope, idx));
}