diff options
| author | 2016-05-03 14:04:02 +0100 | |
|---|---|---|
| committer | 2016-05-04 09:43:22 +0100 | |
| commit | f57e4a48cd77f704d2f33ea457b056fd4ecdde9b (patch) | |
| tree | 740b1e4800344bed7a3ccdf7fe843ae335087f45 | |
| parent | a421e9e758ebb29d3ca7d2b8911e8dfa9a3ded22 (diff) | |
Put a handle on the String object.
Otherwise, a GC could occur in the loop below, and the String
be moved (note that there was already one for the Class object to
protect for that same problem).
bug:27561834
(cherry picked from commit a96f316f6f0526c91c6c102a267df6b1e4df39da)
Change-Id: I89c093dd67982abb3502975097a337c7e3816360
| -rw-r--r-- | runtime/native/java_lang_Class.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index 6b7ca40bee..0624da38c8 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -238,12 +238,13 @@ static mirror::Field* GetPublicFieldRecursive( DCHECK(name != nullptr); DCHECK(self != nullptr); - StackHandleScope<1> hs(self); + StackHandleScope<2> hs(self); MutableHandle<mirror::Class> h_clazz(hs.NewHandle(clazz)); + Handle<mirror::String> h_name(hs.NewHandle(name)); // We search the current class, its direct interfaces then its superclass. while (h_clazz.Get() != nullptr) { - mirror::Field* result = GetDeclaredField(self, h_clazz.Get(), name); + mirror::Field* result = GetDeclaredField(self, h_clazz.Get(), h_name.Get()); if ((result != nullptr) && (result->GetAccessFlags() & kAccPublic)) { return result; } else if (UNLIKELY(self->IsExceptionPending())) { @@ -258,7 +259,7 @@ static mirror::Field* GetPublicFieldRecursive( self->AssertPendingException(); return nullptr; } - result = GetPublicFieldRecursive(self, iface, name); + result = GetPublicFieldRecursive(self, iface, h_name.Get()); if (result != nullptr) { DCHECK(result->GetAccessFlags() & kAccPublic); return result; |