Switch CreateMethodDescriptor over to std::string to avoid memory leaks.
Change-Id: I17005504ab7d055e0750cf35ab2426e0f798f895
diff --git a/src/class_linker.cc b/src/class_linker.cc
index e3912d1..e0461be 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -736,9 +736,8 @@
dst->name_ = ResolveString(dex_file, method_id.name_idx_, klass->GetDexCache());
{
int32_t utf16_length;
- scoped_array<char> utf8(dex_file.CreateMethodDescriptor(method_id.proto_idx_,
- &utf16_length));
- dst->signature_ = String::AllocFromModifiedUtf8(utf16_length, utf8.get());
+ std::string utf8(dex_file.CreateMethodDescriptor(method_id.proto_idx_, &utf16_length));
+ dst->signature_ = String::AllocFromModifiedUtf8(utf16_length, utf8.c_str());
}
dst->proto_idx_ = method_id.proto_idx_;
dst->code_off_ = src.code_off_;
@@ -1878,7 +1877,7 @@
}
const char* name = dex_file.dexStringById(method_id.name_idx_);
- const char* signature = dex_file.CreateMethodDescriptor(method_id.proto_idx_, NULL);
+ std::string signature(dex_file.CreateMethodDescriptor(method_id.proto_idx_, NULL));
if (is_direct) {
resolved = klass->FindDirectMethod(name, signature);
} else {