Add missing SIRT to CreateArrayClass.

component_type was not guarded by a SIRT. This meant that it could
point to a stale object if AllocClass caused a GC.

Bug: 12875306
Change-Id: I387aa53cf461349b183360c37ff69bffbfe54041
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 344da3f..462c328 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2096,10 +2096,11 @@
                                              const SirtRef<mirror::ClassLoader>& class_loader) {
   // Identify the underlying component type
   CHECK_EQ('[', descriptor[0]);
-  mirror::Class* component_type = FindClass(descriptor + 1, class_loader);
-  if (component_type == NULL) {
-    DCHECK(Thread::Current()->IsExceptionPending());
-    return NULL;
+  Thread* self = Thread::Current();
+  SirtRef<mirror::Class> component_type(self, FindClass(descriptor + 1, class_loader));
+  if (component_type.get() == nullptr) {
+    DCHECK(self->IsExceptionPending());
+    return nullptr;
   }
 
   // See if the component type is already loaded.  Array classes are
@@ -2134,7 +2135,6 @@
   //
   // Array classes are simple enough that we don't need to do a full
   // link step.
-  Thread* self = Thread::Current();
   SirtRef<mirror::Class> new_class(self, NULL);
   if (UNLIKELY(!init_done_)) {
     // Classes that were hand created, ie not by FindSystemClass
@@ -2156,12 +2156,12 @@
       new_class.reset(GetClassRoot(kIntArrayClass));
     }
   }
-  if (new_class.get() == NULL) {
+  if (new_class.get() == nullptr) {
     new_class.reset(AllocClass(self, sizeof(mirror::Class)));
-    if (new_class.get() == NULL) {
-      return NULL;
+    if (new_class.get() == nullptr) {
+      return nullptr;
     }
-    new_class->SetComponentType(component_type);
+    new_class->SetComponentType(component_type.get());
   }
   ObjectLock<mirror::Class> lock(self, &new_class);  // Must hold lock on object when initializing.
   DCHECK(new_class->GetComponentType() != NULL);
@@ -2187,7 +2187,7 @@
 
   // Use the single, global copies of "interfaces" and "iftable"
   // (remember not to free them for arrays).
-  CHECK(array_iftable_ != NULL);
+  CHECK(array_iftable_ != nullptr);
   new_class->SetIfTable(array_iftable_);
 
   // Inherit access flags from the component type.
@@ -2202,7 +2202,7 @@
   new_class->SetAccessFlags(access_flags);
 
   mirror::Class* existing = InsertClass(descriptor, new_class.get(), Hash(descriptor));
-  if (existing == NULL) {
+  if (existing == nullptr) {
     return new_class.get();
   }
   // Another thread must have loaded the class after we