summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ujit_codegen.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ujit_codegen.c b/ujit_codegen.c
index 541f74b964..26aa4ffcf0 100644
--- a/ujit_codegen.c
+++ b/ujit_codegen.c
@@ -525,6 +525,15 @@ gen_getinstancevariable(jitstate_t* jit, ctx_t* ctx)
test(cb, flags_opnd, imm_opnd(ROBJECT_EMBED));
jnz_ptr(cb, side_exit);
+ // check that the extended table is big enough
+ if (ivar_index >= ROBJECT_EMBED_LEN_MAX + 1)
+ {
+ // Check that the slot is inside the extended table (num_slots > index)
+ x86opnd_t num_slots = mem_opnd(32, REG0, offsetof(struct RObject, as.heap.numiv));
+ cmp(cb, num_slots, imm_opnd(ivar_index));
+ jle_ptr(cb, side_exit);
+ }
+
// Get a pointer to the extended table
x86opnd_t tbl_opnd = mem_opnd(64, REG0, offsetof(struct RObject, as.heap.ivptr));
mov(cb, REG0, tbl_opnd);