From bf4d3afaf5b408eae7bbd693054447e9b2487505 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Tue, 14 Apr 2015 10:10:33 -0700 Subject: [PATCH] ART: Add a null-check to unstarted-runtime Check the string parameter to Class.forName before using it. Bug: 19542228 Change-Id: I0d5c44122055c46e251451b1c0f687bbaf64d13e --- runtime/interpreter/unstarted_runtime.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc index 4fb634b66..a971c1b3c 100644 --- a/runtime/interpreter/unstarted_runtime.cc +++ b/runtime/interpreter/unstarted_runtime.cc @@ -123,7 +123,12 @@ static void UnstartedClassForName( static void UnstartedClassForNameLong( 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::Object* param = shadow_frame->GetVRegReference(arg_offset); + if (param == nullptr) { + AbortTransactionOrFail(self, "Null-pointer in Class.forName."); + return; + } + mirror::String* class_name = param->AsString(); bool initialize_class = shadow_frame->GetVReg(arg_offset + 1) != 0; mirror::ClassLoader* class_loader = down_cast(shadow_frame->GetVRegReference(arg_offset + 2)); -- 2.11.0