[lldb-test] ir-memory-map: Avoid accessing a bad iterator

Do not access Probe.start() when Probe is at the end of the interval
map.

llvm-svn: 333585
This commit is contained in:
Vedant Kumar 2018-05-30 19:46:47 +00:00
parent b6423479a1
commit f3b6d2930d
1 changed files with 8 additions and 10 deletions

View File

@ -551,8 +551,7 @@ bool opts::irmemorymap::evalMalloc(IRMemoryMap &IRMemMap, StringRef Line,
auto Probe = AllocatedIntervals.begin();
Probe.advanceTo(Addr); //< First interval s.t stop >= Addr.
AllocationT NewAllocation = {Addr, EndOfRegion};
if (Probe != AllocatedIntervals.end()) {
while (Probe.start() < EndOfRegion) {
while (Probe != AllocatedIntervals.end() && Probe.start() < EndOfRegion) {
AllocationT ProbeAllocation = {Probe.start(), Probe.stop()};
if (areAllocationsOverlapping(ProbeAllocation, NewAllocation)) {
outs() << "Malloc error: overlapping allocation detected"
@ -562,7 +561,6 @@ bool opts::irmemorymap::evalMalloc(IRMemoryMap &IRMemMap, StringRef Line,
}
++Probe;
}
}
// Insert the new allocation into the interval map.
if (Size)