bool DexFileVerifier::CheckInterClassDefItem() {
const DexFile::ClassDef* item = reinterpret_cast<const DexFile::ClassDef*>(ptr_);
+ // Check for duplicate class def.
+ if (defined_classes_.find(item->class_idx_) != defined_classes_.end()) {
+ ErrorStringPrintf("Redefinition of class with type idx: '%d'", item->class_idx_);
+ return false;
+ }
+ defined_classes_.insert(item->class_idx_);
+
LOAD_STRING_BY_TYPE(class_descriptor, item->class_idx_, "inter_class_def_item class_idx")
if (UNLIKELY(!IsValidDescriptor(class_descriptor) || class_descriptor[0] != 'L')) {
ErrorStringPrintf("Invalid class descriptor: '%s'", class_descriptor);
#ifndef ART_RUNTIME_DEX_FILE_VERIFIER_H_
#define ART_RUNTIME_DEX_FILE_VERIFIER_H_
+#include <unordered_set>
+
#include "dex_file.h"
#include "safe_map.h"
const void* previous_item_;
std::string failure_reason_;
+
+ // Set of type ids for which there are ClassDef elements in the dex file.
+ std::unordered_set<decltype(DexFile::ClassDef::class_idx_)> defined_classes_;
};
} // namespace art