diff options
| author | 2017-05-09 09:51:35 +0100 | |
|---|---|---|
| committer | 2017-05-10 11:10:06 +0100 | |
| commit | cf7127b4a368ed26eaf257286173d5337f67a0a7 (patch) | |
| tree | 081bae0092d7e4e33176341d1aa2345abb0629b4 | |
| parent | cbf27b379c4632f4b17a07db128ada2db555d591 (diff) | |
ART: Fix null dereference for JSR45
Avoid dereferencing DEX cache pointer if it is null. Arrays and
primitive types do not have DEX cache's installed.
Test: art/tools/run-jdwp-tests.sh --mode=host
Bug: 38126955
Change-Id: I151c18f428d040a4cd9f2fb497c731440bb9fda3
| -rw-r--r-- | runtime/dex_file_annotations.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/dex_file_annotations.cc b/runtime/dex_file_annotations.cc index 13979160bd..f21f1a2704 100644 --- a/runtime/dex_file_annotations.cc +++ b/runtime/dex_file_annotations.cc @@ -1421,11 +1421,20 @@ mirror::ObjectArray<mirror::String>* GetSignatureAnnotationForClass(Handle<mirro } const char* GetSourceDebugExtension(Handle<mirror::Class> klass) { + // Before instantiating ClassData, check that klass has a DexCache + // assigned. The ClassData constructor indirectly dereferences it + // when calling klass->GetDexFile(). + if (klass->GetDexCache() == nullptr) { + DCHECK(klass->IsPrimitive() || klass->IsArrayClass()); + return nullptr; + } + ClassData data(klass); const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); if (annotation_set == nullptr) { return nullptr; } + const DexFile::AnnotationItem* annotation_item = SearchAnnotationSet( data.GetDexFile(), annotation_set, @@ -1434,6 +1443,7 @@ const char* GetSourceDebugExtension(Handle<mirror::Class> klass) { if (annotation_item == nullptr) { return nullptr; } + const uint8_t* annotation = SearchEncodedAnnotation(data.GetDexFile(), annotation_item->annotation_, "value"); if (annotation == nullptr) { |