Skip to content

Commit

Permalink
Fix bug in checking of a mapping exists
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCallahan committed Nov 18, 2016
1 parent e6a26e3 commit 765ef15
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions chromiumos-wide-profiling/address_mapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ bool AddressMapper::GetMappedAddress(const uint64_t real_addr,
uint64_t* mapped_addr) const {
CHECK(mapped_addr);
MappingList::const_iterator iter = find(real_addr);
if (!iter->second.ContainsAddress(real_addr))
if (iter == mappings_.end() ||
!iter->second.ContainsAddress(real_addr))
return false;
*mapped_addr = iter->second.mapped_addr + real_addr - iter->second.real_addr;
return true;
Expand All @@ -182,7 +183,8 @@ bool AddressMapper::GetMappedIDAndOffset(const uint64_t real_addr,
CHECK(id);
CHECK(offset);
MappingList::const_iterator iter = find(real_addr);
if (!iter->second.ContainsAddress(real_addr))
if (iter == mappings_.end() ||
!iter->second.ContainsAddress(real_addr))
return false;

*id = iter->second.id;
Expand Down

0 comments on commit 765ef15

Please sign in to comment.