summaryrefslogtreecommitdiff
path: root/runtime/class_linker-inl.h
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2021-03-30 16:49:15 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2021-03-31 08:18:18 +0000
commit66ab9d6fb28398d7f59a3102ad322aaf06a5c5c2 (patch)
tree41cada937c5d6fe14c29157291afa2b6553acbf8 /runtime/class_linker-inl.h
parenta148d613ed79bc2da889db7830839dec4a797011 (diff)
Workaround for b/145491866
Check if the type is resolved before invoking CheckInvokeClassMismatch. Test: test.py Bug: 145491866 Bug: 73760543 Change-Id: I02714480cef2eece614ef487af60d257f070f46b
Diffstat (limited to 'runtime/class_linker-inl.h')
-rw-r--r--runtime/class_linker-inl.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h
index 69f5a77a25..c45f001aa3 100644
--- a/runtime/class_linker-inl.h
+++ b/runtime/class_linker-inl.h
@@ -320,6 +320,16 @@ inline ArtMethod* ClassLinker::GetResolvedMethod(uint32_t method_idx, ArtMethod*
// Check if the invoke type matches the class type.
ObjPtr<mirror::DexCache> dex_cache = referrer->GetDexCache();
ObjPtr<mirror::ClassLoader> class_loader = referrer->GetClassLoader();
+ const dex::MethodId& method_id = referrer->GetDexFile()->GetMethodId(method_idx);
+ ObjPtr<mirror::Class> cls = LookupResolvedType(method_id.class_idx_, dex_cache, class_loader);
+ if (cls == nullptr) {
+ // The verifier breaks the invariant that a resolved method must have its
+ // class in the class table. Because this method should only lookup and not
+ // resolve class, return null. The caller is responsible for calling
+ // `ResolveMethod` afterwards.
+ // b/73760543
+ return nullptr;
+ }
if (CheckInvokeClassMismatch</* kThrow= */ false>(dex_cache, type, method_idx, class_loader)) {
return nullptr;
}