diff options
author | Christopher Ferris <cferris@google.com> | 2018-05-01 12:59:37 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2018-05-01 14:49:15 -0700 |
commit | c151bc30789ade22d5423b20d2c72948284bba3c (patch) | |
tree | 687fae810571b1147c5ccb0b5f31fb7515489537 /libc/malloc_debug/PointerData.cpp | |
parent | 8602538a15f89f91d6994c3abfd64a274bf7ddb0 (diff) |
Fix nullptr dereference during sort.
Add new unit test that will crash without this fix.
Bug: 78900050
Test: Ran unit tests.
Change-Id: I73e1b89e965a7b399822c3a6f25cbc70d2d355e2
Diffstat (limited to 'libc/malloc_debug/PointerData.cpp')
-rw-r--r-- | libc/malloc_debug/PointerData.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libc/malloc_debug/PointerData.cpp b/libc/malloc_debug/PointerData.cpp index f811a5eb4..85139e607 100644 --- a/libc/malloc_debug/PointerData.cpp +++ b/libc/malloc_debug/PointerData.cpp @@ -392,10 +392,12 @@ void PointerData::GetList(std::vector<ListInfoType>* list, bool only_with_backtr FrameInfoType* b_frame = b.frame_info; if (a_frame == nullptr && b_frame != nullptr) { return false; - } - if (a_frame != nullptr && b_frame == nullptr) { + } else if (a_frame != nullptr && b_frame == nullptr) { return true; + } else if (a_frame == nullptr && b_frame == nullptr) { + return a.pointer < b.pointer; } + // Put the pointers with longest backtrace first. if (a_frame->frames.size() != b_frame->frames.size()) { return a_frame->frames.size() > b_frame->frames.size(); |