Fix 'locals' for methods with arguments that were compiled without -g:locals.
This was a transcription error from the original libdex code. That code translated
the string index anyway and then checked that against NULL, but I think it's both
clearer and closer to the .dex format documentation if we check for NO_INDEX instead.
Change-Id: I1f9c4943641468f5fc2b2c5c5f07f95ac6911677
diff --git a/src/dex_file.cc b/src/dex_file.cc
index d7517c4..5185ba8 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -749,6 +749,7 @@
CHECK(class_def != NULL) << descriptor;
local_in_reg[arg_reg].name_ = "this";
local_in_reg[arg_reg].descriptor_ = GetClassDescriptor(*class_def);
+ local_in_reg[arg_reg].signature_ = NULL;
local_in_reg[arg_reg].start_address_ = 0;
local_in_reg[arg_reg].is_live_ = true;
}
@@ -762,12 +763,13 @@
<< " >= " << code_item->registers_size_ << ")";
return;
}
- int32_t id = DecodeUnsignedLeb128P1(&stream);
+ uint32_t id = DecodeUnsignedLeb128P1(&stream);
const char* descriptor = it.GetDescriptor();
- if (need_locals) {
+ if (need_locals && id != kDexNoIndex) {
const char* name = StringDataByIdx(id);
local_in_reg[arg_reg].name_ = name;
local_in_reg[arg_reg].descriptor_ = descriptor;
+ local_in_reg[arg_reg].signature_ = NULL;
local_in_reg[arg_reg].start_address_ = address;
local_in_reg[arg_reg].is_live_ = true;
}