Check for empty children after dropping overlapping ranges.

Before this changes, the logic checked for empty children before
DropRangesThatOverlapNonOwned in CoalesceOwnedMemory.

This could lead to a NULL added to the children vector, which will
later lead to a crash.  Instead check after drop ranges.

Change-Id: If1321ab618bfabf22dfcaea1c643e88771a52dea
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2906378
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Justin Cohen 2021-05-24 21:50:27 -04:00 committed by Crashpad LUCI CQ
parent b2b65a91cf
commit 161a84977b

View File

@ -172,11 +172,11 @@ void MinidumpMemoryListWriter::AddNonOwnedMemory(
}
void MinidumpMemoryListWriter::CoalesceOwnedMemory() {
DropRangesThatOverlapNonOwned();
if (children_.empty())
return;
DropRangesThatOverlapNonOwned();
std::sort(children_.begin(),
children_.end(),
[](const std::unique_ptr<SnapshotMinidumpMemoryWriter>& a_ptr,