diff options
author | Andreas Gampe <agampe@google.com> | 2015-04-14 22:16:14 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2015-04-14 22:16:14 -0700 |
commit | 5d4bb1d14475dec53347e9e8ad2b8a4f2dd76bf3 (patch) | |
tree | 07bf4abee493119b15cd295ad5d866024df9eac7 /runtime/interpreter | |
parent | 74bf58167e22a781adffe798803105f6541d25a0 (diff) | |
download | art-5d4bb1d14475dec53347e9e8ad2b8a4f2dd76bf3.zip art-5d4bb1d14475dec53347e9e8ad2b8a4f2dd76bf3.tar.gz art-5d4bb1d14475dec53347e9e8ad2b8a4f2dd76bf3.tar.bz2 |
ART: More nullptr checks in unstarted runtime
More checks necessary for the compiler-driver test.
Change-Id: I29bc20d1f571df5407f9b5fca212e3e79ef9cdc7
Diffstat (limited to 'runtime/interpreter')
-rw-r--r-- | runtime/interpreter/unstarted_runtime.cc | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc index fbb07e8..61def35 100644 --- a/runtime/interpreter/unstarted_runtime.cc +++ b/runtime/interpreter/unstarted_runtime.cc @@ -110,10 +110,23 @@ static void CheckExceptionGenerateClassNotFound(Thread* self) } } +static mirror::String* GetClassName(Thread* self, ShadowFrame* shadow_frame, size_t arg_offset) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + mirror::Object* param = shadow_frame->GetVRegReference(arg_offset); + if (param == nullptr) { + AbortTransactionOrFail(self, "Null-pointer in Class.forName."); + return nullptr; + } + return param->AsString(); +} + static void UnstartedClassForName( Thread* self, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::String* class_name = shadow_frame->GetVRegReference(arg_offset)->AsString(); + mirror::String* class_name = GetClassName(self, shadow_frame, arg_offset); + if (class_name == nullptr) { + return; + } StackHandleScope<1> hs(self); Handle<mirror::String> h_class_name(hs.NewHandle(class_name)); UnstartedRuntimeFindClass(self, h_class_name, NullHandle<mirror::ClassLoader>(), result, @@ -124,12 +137,10 @@ static void UnstartedClassForName( static void UnstartedClassForNameLong( Thread* self, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Object* param = shadow_frame->GetVRegReference(arg_offset); - if (param == nullptr) { - AbortTransactionOrFail(self, "Null-pointer in Class.forName."); + mirror::String* class_name = GetClassName(self, shadow_frame, arg_offset); + if (class_name == nullptr) { return; } - mirror::String* class_name = param->AsString(); bool initialize_class = shadow_frame->GetVReg(arg_offset + 1) != 0; mirror::ClassLoader* class_loader = down_cast<mirror::ClassLoader*>(shadow_frame->GetVRegReference(arg_offset + 2)); @@ -144,7 +155,10 @@ static void UnstartedClassForNameLong( static void UnstartedClassClassForName( Thread* self, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::String* class_name = shadow_frame->GetVRegReference(arg_offset)->AsString(); + mirror::String* class_name = GetClassName(self, shadow_frame, arg_offset); + if (class_name == nullptr) { + return; + } bool initialize_class = shadow_frame->GetVReg(arg_offset + 1) != 0; mirror::ClassLoader* class_loader = down_cast<mirror::ClassLoader*>(shadow_frame->GetVRegReference(arg_offset + 2)); @@ -160,7 +174,12 @@ static void UnstartedClassNewInstance( Thread* self, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { StackHandleScope<3> hs(self); // Class, constructor, object. - mirror::Class* klass = shadow_frame->GetVRegReference(arg_offset)->AsClass(); + mirror::Object* param = shadow_frame->GetVRegReference(arg_offset); + if (param == nullptr) { + AbortTransactionOrFail(self, "Null-pointer in Class.newInstance."); + return; + } + mirror::Class* klass = param->AsClass(); Handle<mirror::Class> h_klass(hs.NewHandle(klass)); // Check that it's not null. |