diff options
-rw-r--r-- | runtime/dex_file.cc | 6 | ||||
-rw-r--r-- | runtime/dex_file.h | 1 | ||||
-rw-r--r-- | runtime/native/dalvik_system_VMRuntime.cc | 3 |
3 files changed, 4 insertions, 6 deletions
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc index d3bb483b74..7e09a489be 100644 --- a/runtime/dex_file.cc +++ b/runtime/dex_file.cc @@ -457,9 +457,8 @@ const DexFile::StringId* DexFile::FindStringId(const char* string) const { int32_t hi = NumStringIds() - 1; while (hi >= lo) { int32_t mid = (hi + lo) / 2; - uint32_t length; const DexFile::StringId& str_id = GetStringId(mid); - const char* str = GetStringDataAndUtf16Length(str_id, &length); + const char* str = GetStringData(str_id); int compare = CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(string, str); if (compare > 0) { lo = mid + 1; @@ -477,9 +476,8 @@ const DexFile::StringId* DexFile::FindStringId(const uint16_t* string) const { int32_t hi = NumStringIds() - 1; while (hi >= lo) { int32_t mid = (hi + lo) / 2; - uint32_t length; const DexFile::StringId& str_id = GetStringId(mid); - const char* str = GetStringDataAndUtf16Length(str_id, &length); + const char* str = GetStringData(str_id); int compare = CompareModifiedUtf8ToUtf16AsCodePointValues(str, string); if (compare > 0) { lo = mid + 1; diff --git a/runtime/dex_file.h b/runtime/dex_file.h index 7901ea7447..a9c24e66c1 100644 --- a/runtime/dex_file.h +++ b/runtime/dex_file.h @@ -575,6 +575,7 @@ class DexFile { return StringDataByIdx(GetProtoId(method_id.proto_idx_).shorty_idx_); } const char* GetMethodShorty(const MethodId& method_id, uint32_t* length) const { + // Using the UTF16 length is safe here as shorties are guaranteed to be ASCII characters. return StringDataAndUtf16LengthByIdx(GetProtoId(method_id.proto_idx_).shorty_idx_, length); } // Returns the number of class definitions in the .dex file. diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc index 71ed95c4e2..aef000cf10 100644 --- a/runtime/native/dalvik_system_VMRuntime.cc +++ b/runtime/native/dalvik_system_VMRuntime.cc @@ -221,8 +221,7 @@ static void PreloadDexCachesResolveString(mirror::DexCache* dex_cache, return; } const DexFile* dex_file = dex_cache->GetDexFile(); - uint32_t utf16Size; - const char* utf8 = dex_file->StringDataAndUtf16LengthByIdx(string_idx, &utf16Size); + const char* utf8 = dex_file->StringDataByIdx(string_idx); string = strings[utf8]; if (string == NULL) { return; |