summaryrefslogtreecommitdiffstats
path: root/runtime/mapping_table.h
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2013-11-13 23:31:08 -0800
committerIan Rogers <irogers@google.com>2013-11-13 23:31:08 -0800
commit20ab6c861d248ae2822b5f38d5c09dff7506fc3a (patch)
tree413d09b1bdd37e1dff3fa5014d34f3dd189084d1 /runtime/mapping_table.h
parent202a3e919d1af401fbb4f48e31e71fa2210e7879 (diff)
downloadart-20ab6c861d248ae2822b5f38d5c09dff7506fc3a.zip
art-20ab6c861d248ae2822b5f38d5c09dff7506fc3a.tar.gz
art-20ab6c861d248ae2822b5f38d5c09dff7506fc3a.tar.bz2
Avoid reading off the end of empty mapping tables.
Caught by valgrind. Bug: 11670287 Change-Id: Ia5feacd6780e8e32c7ed600b5908c0b7d7ed7343
Diffstat (limited to 'runtime/mapping_table.h')
-rw-r--r--runtime/mapping_table.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/runtime/mapping_table.h b/runtime/mapping_table.h
index 2162008..9955f30 100644
--- a/runtime/mapping_table.h
+++ b/runtime/mapping_table.h
@@ -68,8 +68,10 @@ class MappingTable {
native_pc_offset_(0), dex_pc_(0) {
if (element == 0) {
encoded_table_ptr_ = table_->FirstDexToPcPtr();
- native_pc_offset_ = DecodeUnsignedLeb128(&encoded_table_ptr_);
- dex_pc_ = DecodeUnsignedLeb128(&encoded_table_ptr_);
+ if (end_ > 0) {
+ native_pc_offset_ = DecodeUnsignedLeb128(&encoded_table_ptr_);
+ dex_pc_ = DecodeUnsignedLeb128(&encoded_table_ptr_);
+ }
} else {
DCHECK_EQ(table_->DexToPcSize(), element);
}
@@ -141,8 +143,10 @@ class MappingTable {
native_pc_offset_(0), dex_pc_(0) {
if (element == 0) {
encoded_table_ptr_ = table_->FirstPcToDexPtr();
- native_pc_offset_ = DecodeUnsignedLeb128(&encoded_table_ptr_);
- dex_pc_ = DecodeUnsignedLeb128(&encoded_table_ptr_);
+ if (end_ > 0) {
+ native_pc_offset_ = DecodeUnsignedLeb128(&encoded_table_ptr_);
+ dex_pc_ = DecodeUnsignedLeb128(&encoded_table_ptr_);
+ }
} else {
DCHECK_EQ(table_->PcToDexSize(), element);
}