Fix JNI error in exception reporting.
There was a JNI error where when you got an OOM and called
report_exception, it would call two NewStringUTF in a row without
checking the return values. This could mean that the first one
threw a new OOME and the second one would cause a JNI error when
it also attempted to throw an OOME with a pending OOME.
Bug: 16843627
(cherry picked from commit cf6775eece8628ac069a6d4803e7f20a017e7e62)
Change-Id: Ibdc7d0e55a48b2a61a1db0868a5d77c2ae53f6f3
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index d82fc96..81e887d 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -179,7 +179,10 @@
env->ExceptionClear();
jstring tagstr = env->NewStringUTF(LOG_TAG);
- jstring msgstr = env->NewStringUTF(msg);
+ jstring msgstr = NULL;
+ if (tagstr != NULL) {
+ msgstr = env->NewStringUTF(msg);
+ }
if ((tagstr == NULL) || (msgstr == NULL)) {
env->ExceptionClear(); /* assume exception (OOM?) was thrown */