Fix possible nullptr dereference.

Test: Unit tests pass.
Change-Id: I046c6e1665de4d941362e2f65605609e77731c97
This commit is contained in:
Christopher Ferris 2022-02-02 17:56:48 -08:00
parent 8266380c77
commit d49ad1e39b

View file

@ -90,11 +90,13 @@ void UnwindLog(const std::vector<unwindstack::LocalFrameData>& frame_info) {
std::shared_ptr<unwindstack::MapInfo> map_info = info->map_info;
std::string line = android::base::StringPrintf(" #%0zd pc %" PAD_PTR " ", i, info->rel_pc);
if (map_info->offset() != 0) {
if (map_info != nullptr && map_info->offset() != 0) {
line += android::base::StringPrintf("(offset 0x%" PRIx64 ") ", map_info->offset());
}
if (map_info->name().empty()) {
if (map_info == nullptr) {
line += "<unknown>";
} else if (map_info->name().empty()) {
line += android::base::StringPrintf("<anonymous:%" PRIx64 ">", map_info->start());
} else {
line += map_info->name();