diff options
author | 2013-02-27 14:36:16 -0800 | |
---|---|---|
committer | 2013-02-27 14:36:16 -0800 | |
commit | 60641a72cdbdbd5d7c731a0544f9ce8555e90dd4 (patch) | |
tree | 12b8a274fb611c1e53824875837ade2fc2ba3380 | |
parent | a0e8bbd2f684f4187ef3d5835a73da8e8ce6dac8 (diff) |
Harden oatdump like we did dexdump.
Bug: 6936283
Change-Id: Ia6bae922b2603e1a2539fe6f2c3b1d69c7594736
-rw-r--r-- | src/utils.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils.cc b/src/utils.cc index 6b93da835d..0416e37d41 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -312,6 +312,9 @@ std::string PrettyField(const mirror::Field* f, bool with_type) { } std::string PrettyField(uint32_t field_idx, const DexFile& dex_file, bool with_type) { + if (field_idx >= dex_file.NumFieldIds()) { + return StringPrintf("<<invalid-field-idx-%d>>", field_idx); + } const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx); std::string result; if (with_type) { @@ -325,6 +328,9 @@ std::string PrettyField(uint32_t field_idx, const DexFile& dex_file, bool with_t } std::string PrettyType(uint32_t type_idx, const DexFile& dex_file) { + if (type_idx >= dex_file.NumTypeIds()) { + return StringPrintf("<<invalid-type-idx-%d>>", type_idx); + } const DexFile::TypeId& type_id = dex_file.GetTypeId(type_idx); return PrettyDescriptor(dex_file.GetTypeDescriptor(type_id)); } @@ -383,6 +389,9 @@ std::string PrettyMethod(const mirror::AbstractMethod* m, bool with_signature) { } std::string PrettyMethod(uint32_t method_idx, const DexFile& dex_file, bool with_signature) { + if (method_idx >= dex_file.NumMethodIds()) { + return StringPrintf("<<invalid-method-idx-%d>>", method_idx); + } const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx); std::string result(PrettyDescriptor(dex_file.GetMethodDeclaringClassDescriptor(method_id))); result += '.'; |