OSDN Git Service

Add null check for thread name creation
authorMathieu Chartier <mathieuc@google.com>
Tue, 11 Nov 2014 00:58:19 +0000 (16:58 -0800)
committerMathieu Chartier <mathieuc@google.com>
Tue, 11 Nov 2014 01:44:38 +0000 (17:44 -0800)
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
Change-Id: I459b1de7760a4009e410fdbdcacdb748d13fbc1d

runtime/thread.cc

index d231525..129c311 100644 (file)
@@ -429,6 +429,10 @@ void Thread::CreatePeer(const char* name, bool as_daemon, jobject thread_group)
     thread_group = runtime->GetMainThreadGroup();
   }
   ScopedLocalRef<jobject> thread_name(env, env->NewStringUTF(name));
+  if (thread_name.get() == nullptr) {
+    CHECK(IsExceptionPending());
+    return;
+  }
   jint thread_priority = GetNativePriority();
   jboolean thread_is_daemon = as_daemon;