summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-02-19 15:19:50 -0800
committerAndreas Gampe <agampe@google.com>2015-02-19 15:19:50 -0800
commitdef194e182ce703077e20bb59025998039fadb75 (patch)
tree1a9cea92901457cd7fbaa0f5c79bcbf010000335
parent42ad490249be898efa1b1196d4ecdbe2cfc3e77b (diff)
downloadart-def194e182ce703077e20bb59025998039fadb75.tar.gz
art-def194e182ce703077e20bb59025998039fadb75.tar.bz2
art-def194e182ce703077e20bb59025998039fadb75.zip
ART: Do not read from JavaVMExt* after DestroyJavaVM
DestroyJavaVM deletes the structure. Change-Id: Ida5fb98a47b1ebf0df7d54506e2fec8958fc105b
-rw-r--r--runtime/check_jni.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/check_jni.cc b/runtime/check_jni.cc
index 6ec0949ce..7db1d7237 100644
--- a/runtime/check_jni.cc
+++ b/runtime/check_jni.cc
@@ -393,7 +393,7 @@ class ScopedCheck {
bool CheckNonHeap(JavaVMExt* vm, bool entry, const char* fmt, JniValueType* args) {
bool should_trace = (flags_ & kFlag_ForceTrace) != 0;
- if (!should_trace && vm->IsTracingEnabled()) {
+ if (!should_trace && vm != nullptr && vm->IsTracingEnabled()) {
// We need to guard some of the invocation interface's calls: a bad caller might
// use DetachCurrentThread or GetEnv on a thread that's not yet attached.
Thread* self = Thread::Current();
@@ -3630,7 +3630,9 @@ class CheckJII {
sc.CheckNonHeap(reinterpret_cast<JavaVMExt*>(vm), true, "v", args);
JniValueType result;
result.i = BaseVm(vm)->DestroyJavaVM(vm);
- sc.CheckNonHeap(reinterpret_cast<JavaVMExt*>(vm), false, "i", &result);
+ // Use null to signal that the JavaVM isn't valid anymore. DestroyJavaVM deletes the runtime,
+ // which will delete the JavaVMExt.
+ sc.CheckNonHeap(nullptr, false, "i", &result);
return result.i;
}