summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2014-08-06 13:39:17 -0700
committer Mathieu Chartier <mathieuc@google.com> 2014-08-06 13:41:19 -0700
commitcf6775eece8628ac069a6d4803e7f20a017e7e62 (patch)
treec7ebc2efc3fbb6282ee4977993be5ee0f3da4d0a
parent8b8c718cbb4ac8d2e6210567d9b6097f428be222 (diff)
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 Change-Id: Ie4f9f9a5f8b7993cd3655d42a6718c0a5e1199f8
-rw-r--r--core/jni/android_util_Binder.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index 662af895e04f..4b2f74050652 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -179,7 +179,10 @@ static void report_exception(JNIEnv* env, jthrowable excep, const char* msg)
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 */