Add null check for thread name creation

Previously we didn't check for null which could result in check jni
failures if we tried to throw another OOM in the next allocation.

Bug: 18297817

(cherry picked from commit a7ade888ab99b1453571d14c41d4a0322c400fcd)

Change-Id: Ideef46f4900e546e81fbd9a5225c06698f36e9ac
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 2c44f27..2c828f1 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -431,6 +431,11 @@
     thread_group = runtime->GetMainThreadGroup();
   }
   ScopedLocalRef<jobject> thread_name(env, env->NewStringUTF(name));
+  // Add missing null check in case of OOM b/18297817
+  if (thread_name.get() == nullptr) {
+    CHECK(IsExceptionPending());
+    return;
+  }
   jint thread_priority = GetNativePriority();
   jboolean thread_is_daemon = as_daemon;