Verifier allows arguments of integral types to be interchangeable.
This fixes a bug where code was passing an int into a method with a
byte argument. The RI allows this, but the verifier was rejecting it.
Bug: 11033423
Change-Id: I2a6af3bbbc6e9288fc000f711ae1337ab5786d1a
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 924a1bb..34ebeb1 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -3082,7 +3082,14 @@
}
const RegType& reg_type = reg_types_.FromDescriptor(class_loader_, descriptor, false);
uint32_t get_reg = is_range ? inst->VRegC_3rc() + actual_args : arg[actual_args];
- if (!work_line_->VerifyRegisterType(get_reg, reg_type)) {
+ if (reg_type.IsIntegralTypes()) {
+ const RegType& src_type = work_line_->GetRegisterType(get_reg);
+ if (!src_type.IsIntegralTypes()) {
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "register v" << get_reg << " has type " << src_type
+ << " but expected " << reg_type;
+ return res_method;
+ }
+ } else if (!work_line_->VerifyRegisterType(get_reg, reg_type)) {
return res_method;
}
actual_args = reg_type.IsLongOrDoubleTypes() ? actual_args + 2 : actual_args + 1;