this should be merged before: [PATCH] vm: only throw NullPointerException on exactly-NULL pointers
Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- jit/object-bc.c | 6 +++--- test/jit/object-bc-test.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/jit/object-bc.c b/jit/object-bc.c index 1252911..972e33b 100644 --- a/jit/object-bc.c +++ b/jit/object-bc.c @@ -139,7 +139,7 @@ int convert_getfield(struct parse_context *ctx) if (!fb) return warn("field lookup failed"), -EINVAL; - objectref = stack_pop(ctx->bb->mimic_stack); + objectref = null_check_expr(stack_pop(ctx->bb->mimic_stack)); value = instance_field_expr(vm_field_type(fb), fb, objectref); if (!value) @@ -165,7 +165,7 @@ int convert_putfield(struct parse_context *ctx) return warn("field lookup failed"), -EINVAL; src = stack_pop(ctx->bb->mimic_stack); - objectref = stack_pop(ctx->bb->mimic_stack); + objectref = null_check_expr(stack_pop(ctx->bb->mimic_stack)); dest = instance_field_expr(vm_field_type(fb), fb, objectref); if (!dest) return -ENOMEM; @@ -488,7 +488,7 @@ int convert_arraylength(struct parse_context *ctx) { struct expression *arrayref, *arraylength_exp; - arrayref = stack_pop(ctx->bb->mimic_stack); + arrayref = null_check_expr(stack_pop(ctx->bb->mimic_stack)); arraylength_exp = arraylength_expr(arrayref); if (!arraylength_exp) diff --git a/test/jit/object-bc-test.c b/test/jit/object-bc-test.c index 4be71f9..02cda9f 100644 --- a/test/jit/object-bc-test.c +++ b/test/jit/object-bc-test.c @@ -598,7 +598,8 @@ void test_convert_arraylength(void) arraylen_exp = stack_pop(bb->mimic_stack); assert_int_equals(EXPR_ARRAYLENGTH, expr_type(arraylen_exp)); assert_int_equals(J_REFERENCE, arraylen_exp->vm_type); - assert_ptr_equals(arrayref, to_expr(arraylen_exp->arraylength_ref)); + assert_nullcheck_value_expr(J_REFERENCE, (unsigned long) class, + arraylen_exp->arraylength_ref); expr_put(arraylen_exp); __free_simple_bb(bb); -- 1.6.0.6 ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel